- Vault creation now prompts for mnemonic if not in environment - Automatically creates passphrase unlocker during vault creation - Prevents 'missing public key' error when adding secrets to new vaults - Updates tests to reflect new vault creation flow
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newCompletionCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "completion [bash|zsh|fish|powershell]",
|
|
Short: "Generate completion script",
|
|
Long: `To load completions:
|
|
|
|
Bash:
|
|
$ source <(secret completion bash)
|
|
# To load completions for each session, execute once:
|
|
# Linux:
|
|
$ secret completion bash > /etc/bash_completion.d/secret
|
|
# macOS:
|
|
$ secret completion bash > $(brew --prefix)/etc/bash_completion.d/secret
|
|
|
|
Zsh:
|
|
# If shell completion is not already enabled in your environment,
|
|
# you will need to enable it. You can execute the following once:
|
|
$ echo "autoload -U compinit; compinit" >> ~/.zshrc
|
|
|
|
# To load completions for each session, execute once:
|
|
$ secret completion zsh > "${fpath[1]}/_secret"
|
|
# You will need to start a new shell for this setup to take effect.
|
|
|
|
Fish:
|
|
$ secret completion fish | source
|
|
# To load completions for each session, execute once:
|
|
$ secret completion fish > ~/.config/fish/completions/secret.fish
|
|
|
|
PowerShell:
|
|
PS> secret completion powershell | Out-String | Invoke-Expression
|
|
# To load completions for every new session, run:
|
|
PS> secret completion powershell > secret.ps1
|
|
# and source this file from your PowerShell profile.
|
|
`,
|
|
DisableFlagsInUseLine: true,
|
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
switch args[0] {
|
|
case "bash":
|
|
return cmd.Root().GenBashCompletion(os.Stdout)
|
|
case "zsh":
|
|
return cmd.Root().GenZshCompletion(os.Stdout)
|
|
case "fish":
|
|
return cmd.Root().GenFishCompletion(os.Stdout, true)
|
|
case "powershell":
|
|
return cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
|
|
default:
|
|
return fmt.Errorf("unsupported shell type: %s", args[0])
|
|
}
|
|
},
|
|
}
|
|
|
|
return cmd
|
|
}
|