mirror of
https://github.com/zrepl/zrepl.git
synced 2024-12-23 23:48:55 +01:00
30 lines
571 B
Go
30 lines
571 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"os"
|
|
)
|
|
|
|
var bashcompCmd = &cobra.Command{
|
|
Use: "bashcomp path/to/out/file",
|
|
Short: "generate bash completions",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) != 1 {
|
|
fmt.Fprintf(os.Stderr, "specify exactly one positional agument\n")
|
|
cmd.Usage()
|
|
os.Exit(1)
|
|
}
|
|
if err := RootCmd.GenBashCompletionFile(args[0]); err != nil {
|
|
fmt.Fprintf(os.Stderr, "error generating bash completion: %s", err)
|
|
os.Exit(1)
|
|
}
|
|
},
|
|
Hidden: true,
|
|
}
|
|
|
|
func init() {
|
|
RootCmd.AddCommand(bashcompCmd)
|
|
}
|