From 6db960bb78fb5775d4eae871704121b999bce897 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 10 Jan 2024 11:04:59 +0100 Subject: [PATCH] refactor: handleCommand -> handleCmd --- ui/input.go | 2 +- ui/input_test.go | 6 +++--- ui/model.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/input.go b/ui/input.go index 28aa4c8..40faef2 100644 --- a/ui/input.go +++ b/ui/input.go @@ -18,7 +18,7 @@ const cmdHelp = `/acn on | Turn on the Tor /start | Show getting started guide /quit | Quit the program` -func handleCommand(cmd, hiddenInput string) tea.Msg { +func handleCmd(cmd, hiddenInput string) tea.Msg { cmds := strings.Split(cmd, " ") switch { diff --git a/ui/input_test.go b/ui/input_test.go index e631f70..06986c4 100644 --- a/ui/input_test.go +++ b/ui/input_test.go @@ -24,7 +24,7 @@ func TestHandleCommandTypes(t *testing.T) { } for _, test := range tests { - msg := handleCommand(test.cmdInput, test.hiddenInput) + msg := handleCmd(test.cmdInput, test.hiddenInput) switch msg := msg.(type) { default: assert.IsType(t, msg, test.cmdOutput) @@ -33,7 +33,7 @@ func TestHandleCommandTypes(t *testing.T) { } func TestHandleCommandUnknownCommand(t *testing.T) { - msg := handleCommand("foo", "") + msg := handleCmd("foo", "") switch msg := msg.(type) { case cmdMsg: assert.Equal(t, msg.output, []string{unknownCmdHelp}) @@ -43,7 +43,7 @@ func TestHandleCommandUnknownCommand(t *testing.T) { } func TestHandleCommandIncorrectCommand(t *testing.T) { - msg := handleCommand("profile foo", "") + msg := handleCmd("profile foo", "") switch msg := msg.(type) { case cmdMsg: assert.Contains(t, msg.output, `Unknown "profile" command?`) diff --git a/ui/model.go b/ui/model.go index c5ee398..fb935aa 100644 --- a/ui/model.go +++ b/ui/model.go @@ -253,7 +253,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } cmds = append(cmds, func() tea.Msg { - return handleCommand(cmdInput[1:], m.hiddenInput) + return handleCmd(cmdInput[1:], m.hiddenInput) }) case "ctrl+n":