From f6c19f92366a1d262e588839791d471f6c0f59db Mon Sep 17 00:00:00 2001 From: Chapman Pendery Date: Tue, 26 Sep 2023 17:36:58 -0700 Subject: [PATCH] fix: tweak cli exposed surface Signed-off-by: Chapman Pendery --- cmd/bind.go | 6 +++--- cmd/root.go | 9 +++++---- shell/shell.go | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/bind.go b/cmd/bind.go index a743427..06a979a 100644 --- a/cmd/bind.go +++ b/cmd/bind.go @@ -15,16 +15,16 @@ func init() { var bindCmd = &cobra.Command{ Use: "bind [shell]", - Short: "adds keybindings to the selected shell", + Short: "adds keybindings to the selected shell " + shell.SupportedShellsText, Args: func(_ *cobra.Command, args []string) error { if len(args) < 1 { - return fmt.Errorf("you must select one of the supported shells: [%s]", strings.Join(shell.SupportedShells, ",")) + return fmt.Errorf("you must select one of the supported shells: %s", shell.SupportedShellsText) } else if len(args) > 1 { return fmt.Errorf("you can only bind to 1 shell at a time") } userSelectedShell := strings.TrimSpace(args[0]) if !slices.Contains(shell.SupportedShells, userSelectedShell) { - return fmt.Errorf("%s is not one of the supported shells: [%s]", userSelectedShell, strings.Join(shell.SupportedShells, ",")) + return fmt.Errorf("%s is not one of the supported shells: %s", userSelectedShell, shell.SupportedShellsText) } return nil }, diff --git a/cmd/root.go b/cmd/root.go index 9ec8254..1d1f8b5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -21,9 +21,10 @@ clac provides inshellisense for the command line to make developers more productive complete documentation is available at https://github.com/cpendery/clac`, - SilenceUsage: true, - Args: cobra.ArbitraryArgs, - RunE: rootExec, + SilenceUsage: true, + Args: cobra.ArbitraryArgs, + RunE: rootExec, + CompletionOptions: cobra.CompletionOptions{HiddenDefaultCmd: true}, } outputCmd bool enableLogging bool @@ -31,7 +32,7 @@ complete documentation is available at https://github.com/cpendery/clac`, func init() { rootCmd.Flags().BoolVarP(&outputCmd, "output-cmd", "o", false, "outputs the last cmd from a clac execution") - rootCmd.Flags().BoolVarP(&enableLogging, "logging", "l", false, "enable logging to the `clac.log` file") + rootCmd.Flags().BoolVarP(&enableLogging, "logging", "l", false, "enable logging to clac.log") } func rootExec(cmd *cobra.Command, args []string) error { diff --git a/shell/shell.go b/shell/shell.go index ff1bef8..5a3d3b2 100644 --- a/shell/shell.go +++ b/shell/shell.go @@ -6,12 +6,14 @@ import ( "os" "path" "runtime" + "strings" "github.com/adrg/xdg" ) var ( - SupportedShells = []string{"bash", "windows-powershell", "powershell"} + SupportedShells = []string{"bash", "zsh", "windows-powershell", "powershell"} + SupportedShellsText = "[" + strings.Join(SupportedShells, ", ") + "]" ) const (