completioncmd

package
v0.0.3-alpha.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CompletionCommand = redant.Command{
	Use:   "completion [shell]",
	Short: "Generate the autocompletion script for the specified shell",
	Long: `Generate the autocompletion script for redant for the specified shell.
See each sub-command's help for details on how to use the generated script.`,
	Handler: func(ctx context.Context, inv *redant.Invocation) error {
		if len(inv.Args) == 0 {
			fmt.Fprintf(inv.Stderr, "error: shell argument is required. Available shells: bash, zsh, fish\n")
			return fmt.Errorf("missing shell argument")
		}

		shell := inv.Args[0]
		switch shell {
		case "bash":
			return generateBashCompletion(ctx, inv)
		case "zsh":
			return generateZshCompletion(ctx, inv)
		case "fish":
			return generateFishCompletion(ctx, inv)
		default:
			fmt.Fprintf(inv.Stderr, "error: unsupported shell: %s. Available shells: bash, zsh, fish\n", shell)
			return fmt.Errorf("unsupported shell: %s", shell)
		}
	},
}

CompletionCommand is a built-in command for generating shell completion scripts

Functions

func AddCompletionCommand

func AddCompletionCommand(rootCmd *redant.Command)

AddCompletionCommand adds the completion command to the root command

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL