Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
address feedback, remove TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jul 17, 2017
1 parent 64e7303 commit c0e03dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion autocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/posener/complete/cmd/install"
)

// autocompleteInstaller is an interface to be implemented to peform the
// autocompleteInstaller is an interface to be implemented to perform the
// autocomplete installation and uninstallation with a CLI.
//
// This interface is not exported because it only exists for unit tests
Expand Down
8 changes: 6 additions & 2 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ func (c *CLI) Run() (int, error) {

// If both install and uninstall flags are specified, then error
if c.isAutocompleteInstall && c.isAutocompleteUninstall {
// TODO: Write error message
return 1, nil
return 1, fmt.Errorf(
"Either the autocomplete install or uninstall flag may " +
"be specified, but not both.")
}

// If the install flag is specified, perform the install or uninstall
Expand Down Expand Up @@ -383,6 +384,9 @@ func (c *CLI) initAutocomplete() {
c.autocomplete = complete.New(c.Name, cmd)
}

// initAutocompleteSub creates the complete.Command for a subcommand with
// the given prefix. This will continue recursively for all subcommands.
// The prefix "" (empty string) can be used for the root command.
func (c *CLI) initAutocompleteSub(prefix string) complete.Command {
var cmd complete.Command
walkFn := func(k string, raw interface{}) bool {
Expand Down
4 changes: 2 additions & 2 deletions cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,8 @@ func TestCLIRun_autocompleteBoth(t *testing.T) {
}

exitCode, err := cli.Run()
if err != nil {
t.Fatalf("err: %s", err)
if err == nil {
t.Fatal("should error")
}

if exitCode != 1 {
Expand Down

0 comments on commit c0e03dd

Please sign in to comment.