From d5b07f48376cef9f62e12e3b56bcdd7483ef588f Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 27 Dec 2022 17:23:56 +0100 Subject: commands: move bug specific input code into commands/bug/input --- termui/termui.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'termui/termui.go') diff --git a/termui/termui.go b/termui/termui.go index 79577ba9..d640ed1c 100644 --- a/termui/termui.go +++ b/termui/termui.go @@ -8,7 +8,7 @@ import ( "github.com/pkg/errors" "github.com/MichaelMure/git-bug/cache" - "github.com/MichaelMure/git-bug/commands/input" + buginput "github.com/MichaelMure/git-bug/commands/bug/input" "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/query" "github.com/MichaelMure/git-bug/util/text" @@ -187,14 +187,14 @@ func newBugWithEditor(repo *cache.RepoCache) error { ui.g.Close() ui.g = nil - title, message, err := input.BugCreateEditorInput(ui.cache, "", "") + title, message, err := buginput.BugCreateEditorInput(ui.cache, "", "") - if err != nil && err != input.ErrEmptyTitle { + if err != nil && err != buginput.ErrEmptyTitle { return err } var b *cache.BugCache - if err == input.ErrEmptyTitle { + if err == buginput.ErrEmptyTitle { ui.msgPopup.Activate(msgPopupErrorTitle, "Empty title, aborting.") initGui(nil) @@ -230,13 +230,11 @@ func addCommentWithEditor(bug *cache.BugCache) error { ui.g.Close() ui.g = nil - message, err := input.BugCommentEditorInput(ui.cache, "") - - if err != nil && err != input.ErrEmptyMessage { + message, err := buginput.BugCommentEditorInput(ui.cache, "") + if err != nil && err != buginput.ErrEmptyMessage { return err } - - if err == input.ErrEmptyMessage { + if err == buginput.ErrEmptyMessage { ui.msgPopup.Activate(msgPopupErrorTitle, "Empty message, aborting.") } else { _, _, err := bug.AddComment(text.Cleanup(message)) @@ -263,12 +261,12 @@ func editCommentWithEditor(bug *cache.BugCache, target entity.CombinedId, preMes ui.g.Close() ui.g = nil - message, err := input.BugCommentEditorInput(ui.cache, preMessage) - if err != nil && err != input.ErrEmptyMessage { + message, err := buginput.BugCommentEditorInput(ui.cache, preMessage) + if err != nil && err != buginput.ErrEmptyMessage { return err } - if err == input.ErrEmptyMessage { + if err == buginput.ErrEmptyMessage { // TODO: Allow comments to be deleted? ui.msgPopup.Activate(msgPopupErrorTitle, "Empty message, aborting.") } else if message == preMessage { @@ -300,13 +298,13 @@ func setTitleWithEditor(bug *cache.BugCache) error { snap := bug.Snapshot() - title, err := input.BugTitleEditorInput(ui.cache, snap.Title) + title, err := buginput.BugTitleEditorInput(ui.cache, snap.Title) - if err != nil && err != input.ErrEmptyTitle { + if err != nil && err != buginput.ErrEmptyTitle { return err } - if err == input.ErrEmptyTitle { + if err == buginput.ErrEmptyTitle { ui.msgPopup.Activate(msgPopupErrorTitle, "Empty title, aborting.") } else if title == snap.Title { ui.msgPopup.Activate(msgPopupErrorTitle, "No change, aborting.") @@ -335,7 +333,7 @@ func editQueryWithEditor(bt *bugTable) error { ui.g.Close() ui.g = nil - queryStr, err := input.QueryEditorInput(bt.repo, bt.queryStr) + queryStr, err := buginput.QueryEditorInput(bt.repo, bt.queryStr) if err != nil { return err -- cgit