Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ion #338

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions completers/ion_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -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()
}
}),
)
}
7 changes: 7 additions & 0 deletions completers/ion_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/ion_completer/cmd"

func main() {
cmd.Execute()
}