From f69cf8a310c04f8634c0fdefb1e07181fe30ce5d Mon Sep 17 00:00:00 2001 From: rsteube Date: Wed, 31 Mar 2021 23:08:27 +0200 Subject: [PATCH] added ion --- completers/ion_completer/cmd/root.go | 42 ++++++++++++++++++++++++++++ completers/ion_completer/main.go | 7 +++++ 2 files changed, 49 insertions(+) create mode 100644 completers/ion_completer/cmd/root.go create mode 100644 completers/ion_completer/main.go diff --git a/completers/ion_completer/cmd/root.go b/completers/ion_completer/cmd/root.go new file mode 100644 index 0000000000..54f4f48f14 --- /dev/null +++ b/completers/ion_completer/cmd/root.go @@ -0,0 +1,42 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "ion", + Short: "", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func Execute() error { + return rootCmd.Execute() +} +func init() { + carapace.Gen(rootCmd).Standalone() + + rootCmd.Flags().StringS("c", "c", "", "Evaluate given commands instead of reading from the commandline") + rootCmd.Flags().StringS("o", "o", "", "Shortcut layout.") + rootCmd.Flags().BoolS("x", "x", false, "Print commands before execution") + rootCmd.Flags().BoolP("fake-interactive", "f", false, "Use a fake interactive mode, where errors don't exit the shell") + rootCmd.Flags().BoolP("help", "h", false, "Prints help information") + rootCmd.Flags().BoolP("interactive", "i", false, "Force interactive mode") + rootCmd.Flags().BoolP("no-execute", "n", false, "Do not execute any commands, perform only syntax checking") + rootCmd.Flags().BoolP("version", "v", false, "Print the version, platform and revision of Ion then exit") + + carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ + "o": carapace.ActionValues("vi", "emacs"), + }) + + carapace.Gen(rootCmd).PositionalCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + if !rootCmd.Flag("c").Changed { + return carapace.ActionFiles() + } else { + return carapace.ActionValues() + } + }), + ) +} diff --git a/completers/ion_completer/main.go b/completers/ion_completer/main.go new file mode 100644 index 0000000000..7a3519a27d --- /dev/null +++ b/completers/ion_completer/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/rsteube/carapace-bin/completers/ion_completer/cmd" + +func main() { + cmd.Execute() +}