From a11f95cfcdea2ff995b736f2a7859a4e3e29de59 Mon Sep 17 00:00:00 2001 From: rsteube Date: Sat, 22 Jan 2022 14:07:51 +0100 Subject: [PATCH] added brew --- .../brew_completer/cmd/action/action.go | 22 +++++ completers/brew_completer/cmd/action/list.go | 18 ++++ .../brew_completer/cmd/action/search.go | 31 +++++++ completers/brew_completer/cmd/config.go | 22 +++++ completers/brew_completer/cmd/create.go | 40 +++++++++ completers/brew_completer/cmd/doctor.go | 24 ++++++ completers/brew_completer/cmd/edit.go | 32 +++++++ completers/brew_completer/cmd/info.go | 42 +++++++++ completers/brew_completer/cmd/install.go | 85 +++++++++++++++++++ completers/brew_completer/cmd/list.go | 42 +++++++++ completers/brew_completer/cmd/root.go | 21 +++++ completers/brew_completer/cmd/search.go | 36 ++++++++ completers/brew_completer/cmd/uninstall.go | 36 ++++++++ completers/brew_completer/cmd/update.go | 24 ++++++ completers/brew_completer/cmd/upgrade.go | 81 ++++++++++++++++++ completers/brew_completer/main.go | 7 ++ 16 files changed, 563 insertions(+) create mode 100644 completers/brew_completer/cmd/action/action.go create mode 100644 completers/brew_completer/cmd/action/list.go create mode 100644 completers/brew_completer/cmd/action/search.go create mode 100644 completers/brew_completer/cmd/config.go create mode 100644 completers/brew_completer/cmd/create.go create mode 100644 completers/brew_completer/cmd/doctor.go create mode 100644 completers/brew_completer/cmd/edit.go create mode 100644 completers/brew_completer/cmd/info.go create mode 100644 completers/brew_completer/cmd/install.go create mode 100644 completers/brew_completer/cmd/list.go create mode 100644 completers/brew_completer/cmd/root.go create mode 100644 completers/brew_completer/cmd/search.go create mode 100644 completers/brew_completer/cmd/uninstall.go create mode 100644 completers/brew_completer/cmd/update.go create mode 100644 completers/brew_completer/cmd/upgrade.go create mode 100644 completers/brew_completer/main.go diff --git a/completers/brew_completer/cmd/action/action.go b/completers/brew_completer/cmd/action/action.go new file mode 100644 index 0000000000..520f73c6b0 --- /dev/null +++ b/completers/brew_completer/cmd/action/action.go @@ -0,0 +1,22 @@ +package action + +import ( + "github.com/spf13/cobra" +) + +func defaultArgs(cmd *cobra.Command) []string { + args := make([]string, 0) + + if flag := cmd.Flag("formula"); flag != nil && flag.Changed { + args = append(args, "--formula") + } else if flag := cmd.Flag("formulae"); flag != nil && flag.Changed { + args = append(args, "--formulae") + } + + if flag := cmd.Flag("cask"); flag != nil && flag.Changed { + args = append(args, "--cask") + } else if flag := cmd.Flag("casks"); flag != nil && flag.Changed { + args = append(args, "--casks") + } + return args +} diff --git a/completers/brew_completer/cmd/action/list.go b/completers/brew_completer/cmd/action/list.go new file mode 100644 index 0000000000..7a6933e240 --- /dev/null +++ b/completers/brew_completer/cmd/action/list.go @@ -0,0 +1,18 @@ +package action + +import ( + "strings" + + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +func ActionList(cmd *cobra.Command) carapace.Action { + return carapace.ActionCallback(func(c carapace.Context) carapace.Action { + args := append([]string{"list"}, defaultArgs(cmd)...) + return carapace.ActionExecCommand("brew", args...)(func(output []byte) carapace.Action { + lines := strings.Split(string(output), "\n") + return carapace.ActionValues(lines[:len(lines)-1]...) + }) + }) +} diff --git a/completers/brew_completer/cmd/action/search.go b/completers/brew_completer/cmd/action/search.go new file mode 100644 index 0000000000..f69e1f8a0c --- /dev/null +++ b/completers/brew_completer/cmd/action/search.go @@ -0,0 +1,31 @@ +package action + +import ( + "fmt" + "strings" + + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +func ActionSearch(cmd *cobra.Command) carapace.Action { + return carapace.ActionCallback(func(c carapace.Context) carapace.Action { + if len(c.CallbackValue) < 2 { + return carapace.ActionMessage("search needs at least 2 characters") + } + + args := append([]string{"search"}, defaultArgs(cmd)...) + args = append(args, fmt.Sprintf("/^%v/", c.CallbackValue)) + return carapace.ActionExecCommand("brew", args...)(func(output []byte) carapace.Action { + lines := strings.Split(string(output), "\n") + + vals := make([]string, 0) + for _, line := range lines { + if !strings.HasPrefix(line, "==>") { + vals = append(vals, line) + } + } + return carapace.ActionValues(vals...) + }) + }) +} diff --git a/completers/brew_completer/cmd/config.go b/completers/brew_completer/cmd/config.go new file mode 100644 index 0000000000..b1797a8c9a --- /dev/null +++ b/completers/brew_completer/cmd/config.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var configCmd = &cobra.Command{ + Use: "config", + Short: "Show Homebrew and system configuration info useful for debugging", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(configCmd).Standalone() + + configCmd.Flags().BoolP("debug", "d", false, "Display any debugging information.") + configCmd.Flags().BoolP("help", "h", false, "Show this message.") + configCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet.") + configCmd.Flags().BoolP("verbose", "v", false, "Make some output more verbose.") + rootCmd.AddCommand(configCmd) +} diff --git a/completers/brew_completer/cmd/create.go b/completers/brew_completer/cmd/create.go new file mode 100644 index 0000000000..b518361394 --- /dev/null +++ b/completers/brew_completer/cmd/create.go @@ -0,0 +1,40 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var createCmd = &cobra.Command{ + Use: "create", + Short: "Generate a formula or a cask for the downloadable file at URL", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(createCmd).Standalone() + + createCmd.Flags().Bool("HEAD", false, "Indicate that URL points to the package's repository rather than a file.") + createCmd.Flags().Bool("autotools", false, "Create a basic template for an Autotools-style build.") + createCmd.Flags().Bool("cask", false, "Create a basic template for a cask.") + createCmd.Flags().Bool("cmake", false, "Create a basic template for a CMake-style build.") + createCmd.Flags().Bool("crystal", false, "Create a basic template for a Crystal build.") + createCmd.Flags().BoolP("debug", "d", false, "Display any debugging information.") + createCmd.Flags().BoolP("force", "f", false, "Ignore errors for disallowed formula names") + createCmd.Flags().Bool("go", false, "Create a basic template for a Go build.") + createCmd.Flags().BoolP("help", "h", false, "Show this message.") + createCmd.Flags().Bool("meson", false, "Create a basic template for a Meson-style build.") + createCmd.Flags().Bool("no-fetch", false, "Homebrew will not download URL to the cache") + createCmd.Flags().Bool("node", false, "Create a basic template for a Node build.") + createCmd.Flags().Bool("perl", false, "Create a basic template for a Perl build.") + createCmd.Flags().Bool("python", false, "Create a basic template for a Python build.") + createCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet.") + createCmd.Flags().Bool("ruby", false, "Create a basic template for a Ruby build.") + createCmd.Flags().Bool("rust", false, "Create a basic template for a Rust build.") + createCmd.Flags().Bool("set-license", false, "Explicitly set the license of the new formula.") + createCmd.Flags().Bool("set-name", false, "Explicitly set the name of the new formula or cask.") + createCmd.Flags().Bool("set-version", false, "Explicitly set the version of the new formula or cask.") + createCmd.Flags().Bool("tap", false, "Generate the new formula within the given tap") + createCmd.Flags().BoolP("verbose", "v", false, "Make some output more verbose.") + rootCmd.AddCommand(createCmd) +} diff --git a/completers/brew_completer/cmd/doctor.go b/completers/brew_completer/cmd/doctor.go new file mode 100644 index 0000000000..d869247d6f --- /dev/null +++ b/completers/brew_completer/cmd/doctor.go @@ -0,0 +1,24 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var doctorCmd = &cobra.Command{ + Use: "doctor", + Short: "Check your system for potential problems", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(doctorCmd).Standalone() + + doctorCmd.Flags().BoolP("audit-debug", "D", false, "Enable debugging and profiling of audit methods.") + doctorCmd.Flags().BoolP("debug", "d", false, "Display any debugging information.") + doctorCmd.Flags().BoolP("help", "h", false, "Show this message.") + doctorCmd.Flags().Bool("list-checks", false, "List all audit methods") + doctorCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet.") + doctorCmd.Flags().BoolP("verbose", "v", false, "Make some output more verbose.") + rootCmd.AddCommand(doctorCmd) +} diff --git a/completers/brew_completer/cmd/edit.go b/completers/brew_completer/cmd/edit.go new file mode 100644 index 0000000000..356514b490 --- /dev/null +++ b/completers/brew_completer/cmd/edit.go @@ -0,0 +1,32 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/completers/brew_completer/cmd/action" + "github.com/spf13/cobra" +) + +var editCmd = &cobra.Command{ + Use: "edit", + Short: "Open a formula or cask in the editor", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(editCmd).Standalone() + + editCmd.Flags().Bool("cask", false, "Treat all named arguments as casks.") + editCmd.Flags().Bool("casks", false, "Treat all named arguments as casks.") + editCmd.Flags().BoolP("debug", "d", false, "Display any debugging information.") + editCmd.Flags().Bool("formula", false, "Treat all named arguments as formulae.") + editCmd.Flags().Bool("formulae", false, "Treat all named arguments as formulae.") + editCmd.Flags().BoolP("help", "h", false, "Show this message.") + editCmd.Flags().Bool("print-path", false, "Print the file path to be edited") + editCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet.") + editCmd.Flags().BoolP("verbose", "v", false, "Make some output more verbose.") + rootCmd.AddCommand(editCmd) + + carapace.Gen(editCmd).PositionalAnyCompletion( + action.ActionList(editCmd), + ) +} diff --git a/completers/brew_completer/cmd/info.go b/completers/brew_completer/cmd/info.go new file mode 100644 index 0000000000..4e2689962f --- /dev/null +++ b/completers/brew_completer/cmd/info.go @@ -0,0 +1,42 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/completers/brew_completer/cmd/action" + "github.com/spf13/cobra" +) + +var infoCmd = &cobra.Command{ + Use: "info", + Short: "Display brief statistics for your Homebrew installation", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(infoCmd).Standalone() + + infoCmd.Flags().Bool("all", false, "Print JSON of all available formulae") + infoCmd.Flags().Bool("analytics", false, "List global Homebrew analytics data") + infoCmd.Flags().Bool("cask", false, "Treat all named arguments as casks") + infoCmd.Flags().Bool("casks", false, "Treat all named arguments as casks") + infoCmd.Flags().String("category", "", "Which type of analytics data to retrieve") + infoCmd.Flags().String("days", "", "How many days of analytics data to retrieve") + infoCmd.Flags().BoolP("debug", "d", false, "Display any debugging information") + infoCmd.Flags().Bool("formula", false, "Treat all named arguments as formulae") + infoCmd.Flags().Bool("formulae", false, "Treat all named arguments as formulae") + infoCmd.Flags().Bool("github", false, "Open the GitHub source page for formula and cask in a browser") + infoCmd.Flags().BoolP("help", "h", false, "Show this message") + infoCmd.Flags().Bool("installed", false, "Print JSON of formulae that are currently installed") + infoCmd.Flags().Bool("json", false, "Print a JSON representation") + infoCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet") + infoCmd.Flags().BoolP("verbose", "v", false, "Show more verbose analytics data for formula") + rootCmd.AddCommand(infoCmd) + + carapace.Gen(infoCmd).FlagCompletion(carapace.ActionMap{ + "category": carapace.ActionValues("install", "install-on-request", "build-error"), + }) + + carapace.Gen(installCmd).PositionalAnyCompletion( + action.ActionSearch(installCmd), + ) +} diff --git a/completers/brew_completer/cmd/install.go b/completers/brew_completer/cmd/install.go new file mode 100644 index 0000000000..c5d91f8999 --- /dev/null +++ b/completers/brew_completer/cmd/install.go @@ -0,0 +1,85 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/completers/brew_completer/cmd/action" + "github.com/spf13/cobra" +) + +var installCmd = &cobra.Command{ + Use: "install", + Short: "Install a formula or cask", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(installCmd).Standalone() + + installCmd.Flags().Bool("HEAD", false, "If formula defines it, install the HEAD version") + installCmd.Flags().String("appdir", "", "Target location for Applications") + installCmd.Flags().String("audio-unit-plugindir", "", "Target location for Audio Unit Plugins") + installCmd.Flags().Bool("binaries", false, "Enable linking of helper executables") + installCmd.Flags().String("bottle-arch", "", "Optimise bottles for the specified architecture") + installCmd.Flags().Bool("build-bottle", false, "Prepare the formula for eventual bottling during installation") + installCmd.Flags().BoolP("build-from-source", "s", false, "Compile formula from source even if a bottle is provided") + installCmd.Flags().Bool("cask", false, "Treat all named arguments as casks") + installCmd.Flags().Bool("casks", false, "Treat all named arguments as casks") + installCmd.Flags().Bool("cc", false, "Attempt to compile using the specified compiler") + installCmd.Flags().String("colorpickerdir", "", "Target location for Color Pickers") + installCmd.Flags().BoolP("debug", "d", false, "If brewing fails, open an interactive debugging session") + installCmd.Flags().String("dictionarydir", "", "Target location for Dictionaries (default:") + installCmd.Flags().Bool("display-times", false, "Print install times for each package at the end of the run") + installCmd.Flags().Bool("fetch-HEAD", false, "Fetch the upstream repository to detect if the HEAD installation of the formula is outdated") + installCmd.Flags().String("fontdir", "", "Target location for Fonts (default:") + installCmd.Flags().BoolP("force", "f", false, "Install formulae without checking for previously installed") + installCmd.Flags().Bool("force-bottle", false, "Install from a bottle even if it would not normally be used for installation") + installCmd.Flags().Bool("formula", false, "Treat all named arguments as formulae") + installCmd.Flags().Bool("formulae", false, "Treat all named arguments as formulae") + installCmd.Flags().BoolP("git", "g", false, "Create a Git repository") + installCmd.Flags().BoolP("help", "h", false, "Show this message.") + installCmd.Flags().Bool("ignore-dependencies", false, "An unsupported Homebrew development flag to skip installing any dependencies") + installCmd.Flags().Bool("include-test", false, "Install testing dependencies required to run brew test formula") + installCmd.Flags().String("input-methoddir", "", "Target location for Input Methods (default:") + installCmd.Flags().BoolP("interactive", "i", false, "Download and patch formula, then open a shell") + installCmd.Flags().String("internet-plugindir", "", "Target location for Internet Plugins") + installCmd.Flags().Bool("keep-tmp", false, "Retain the temporary files created during installation") + installCmd.Flags().String("language", "", "Comma-separated list of language codes to prefer for cask installation") + installCmd.Flags().String("mdimporterdir", "", "Target location for Spotlight Plugins") + installCmd.Flags().Bool("no-binaries", false, "Disable linking of helper executables") + installCmd.Flags().Bool("no-quarantine", false, "Disable quarantining of downloads") + installCmd.Flags().Bool("only-dependencies", false, "Install the dependencies with specified options") + installCmd.Flags().Bool("overwrite", false, "Delete files that already exist in the prefix while linking") + installCmd.Flags().String("prefpanedir", "", "Target location for Preference Panes") + installCmd.Flags().String("qlplugindir", "", "Target location for QuickLook Plugins") + installCmd.Flags().Bool("quarantine", false, "Enable quarantining of downloads") + installCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet.") + installCmd.Flags().Bool("require-sha", false, "Require all casks to have a checksum.") + installCmd.Flags().String("screen-saverdir", "", "Target location for Screen Savers (default:") + installCmd.Flags().String("servicedir", "", "Target location for Services (default:") + installCmd.Flags().Bool("skip-cask-deps", false, "Skip installing cask dependencies") + installCmd.Flags().BoolP("verbose", "v", false, "Print the verification and postinstall steps") + installCmd.Flags().String("vst-plugindir", "", "Target location for VST Plugins (default:") + installCmd.Flags().String("vst3-plugindir", "", "Target location for VST3 Plugins (default:") + rootCmd.AddCommand(installCmd) + + carapace.Gen(installCmd).FlagCompletion(carapace.ActionMap{ + "appdir": carapace.ActionDirectories(), + "audio-unit-plugindir": carapace.ActionDirectories(), + "colorpickerdir": carapace.ActionDirectories(), + "dictionarydir": carapace.ActionDirectories(), + "fontdir": carapace.ActionDirectories(), + "input-methoddir": carapace.ActionDirectories(), + "internet-plugindir": carapace.ActionDirectories(), + "mdimporterdir": carapace.ActionDirectories(), + "prefpanedir": carapace.ActionDirectories(), + "qlplugindir": carapace.ActionDirectories(), + "screen-saverdir": carapace.ActionDirectories(), + "servicedir": carapace.ActionDirectories(), + "vst-plugindir": carapace.ActionDirectories(), + "vst3-plugindir": carapace.ActionDirectories(), + }) + + carapace.Gen(installCmd).PositionalAnyCompletion( + action.ActionSearch(installCmd), + ) +} diff --git a/completers/brew_completer/cmd/list.go b/completers/brew_completer/cmd/list.go new file mode 100644 index 0000000000..3c9c6644a1 --- /dev/null +++ b/completers/brew_completer/cmd/list.go @@ -0,0 +1,42 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/completers/brew_completer/cmd/action" + "github.com/spf13/cobra" +) + +var listCmd = &cobra.Command{ + Use: "list", + Short: "List all installed formulae and casks", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(listCmd).Standalone() + + listCmd.Flags().BoolS("1", "1", false, "Force output to be one entry per line") + listCmd.Flags().Bool("cask", false, "List only casks, or treat all named arguments as casks.") + listCmd.Flags().Bool("casks", false, "List only casks, or treat all named arguments as casks.") + listCmd.Flags().BoolP("debug", "d", false, "Display any debugging information.") + listCmd.Flags().Bool("formula", false, "List only formulae, or treat all named arguments as formulae.") + listCmd.Flags().Bool("formulae", false, "List only formulae, or treat all named arguments as formulae.") + listCmd.Flags().Bool("full-name", false, "Print formulae with fully-qualified names.") + listCmd.Flags().BoolP("help", "h", false, "Show this message.") + listCmd.Flags().BoolS("l", "l", false, "List formulae and/or casks in long format.") + listCmd.Flags().Bool("multiple", false, "Only show formulae with multiple versions installed") + listCmd.Flags().Bool("pinned", false, "List only pinned formulae") + listCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet.") + listCmd.Flags().BoolS("r", "r", false, "Reverse the order of the formulae") + listCmd.Flags().BoolS("t", "t", false, "Sort formulae and/or casks by time modified") + listCmd.Flags().Bool("unbrewed", false, "List files in Homebrew's prefix not installed by Homebrew.") + listCmd.Flags().BoolP("verbose", "v", false, "Make some output more verbose.") + listCmd.Flags().Bool("versions", false, "Show the version number for installed formulae") + rootCmd.AddCommand(listCmd) + + carapace.Gen(listCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + return action.ActionList(listCmd).Invoke(c).Filter(c.Args).ToA() + }), + ) +} diff --git a/completers/brew_completer/cmd/root.go b/completers/brew_completer/cmd/root.go new file mode 100644 index 0000000000..c31fb9dfc4 --- /dev/null +++ b/completers/brew_completer/cmd/root.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "brew", + Short: "The missing package manager for macOS", + Long: "https://brew.sh/", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func Execute() error { + return rootCmd.Execute() +} +func init() { + carapace.Gen(rootCmd).Standalone() + +} diff --git a/completers/brew_completer/cmd/search.go b/completers/brew_completer/cmd/search.go new file mode 100644 index 0000000000..ea859b77a3 --- /dev/null +++ b/completers/brew_completer/cmd/search.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var Cmd = &cobra.Command{ + Use: "search", + Short: "Perform a substring search of cask tokens and formula names", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(Cmd).Standalone() + + Cmd.Flags().Bool("archlinux", false, "Search for text in the given database.") + Cmd.Flags().String("cask", "", "Search online and locally for casks.") + Cmd.Flags().Bool("closed", false, "Search for only closed GitHub pull requests.") + Cmd.Flags().Bool("debian", false, "Search for text in the given database.") + Cmd.Flags().BoolP("debug", "d", false, "Display any debugging information.") + Cmd.Flags().Bool("desc", false, "Search for formulae with a description") + Cmd.Flags().Bool("fedora", false, "Search for text in the given database.") + Cmd.Flags().Bool("fink", false, "Search for text in the given database.") + Cmd.Flags().String("formula", "", "Search online and locally for formulae.") + Cmd.Flags().BoolP("help", "h", false, "Show this message.") + Cmd.Flags().Bool("macports", false, "Search for text in the given database.") + Cmd.Flags().Bool("open", false, "Search for only open GitHub pull requests.") + Cmd.Flags().Bool("opensuse", false, "Search for text in the given database.") + Cmd.Flags().Bool("pull-request", false, "Search for GitHub pull requests containing") + Cmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet.") + Cmd.Flags().Bool("repology", false, "Search for text in the given database.") + Cmd.Flags().Bool("ubuntu", false, "Search for text in the given database.") + Cmd.Flags().BoolP("verbose", "v", false, "Make some output more verbose.") + rootCmd.AddCommand(Cmd) +} diff --git a/completers/brew_completer/cmd/uninstall.go b/completers/brew_completer/cmd/uninstall.go new file mode 100644 index 0000000000..d776fc367e --- /dev/null +++ b/completers/brew_completer/cmd/uninstall.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/completers/brew_completer/cmd/action" + "github.com/spf13/cobra" +) + +var uninstallCmd = &cobra.Command{ + Use: "uninstall", + Short: "Uninstall a formula or cask", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(uninstallCmd).Standalone() + + uninstallCmd.Flags().Bool("cask", false, "Treat all named arguments as casks.") + uninstallCmd.Flags().Bool("casks", false, "Treat all named arguments as casks.") + uninstallCmd.Flags().BoolP("debug", "d", false, "Display any debugging information.") + uninstallCmd.Flags().BoolP("force", "f", false, "Delete all installed versions of formula.") + uninstallCmd.Flags().Bool("formula", false, "Treat all named arguments as formulae.") + uninstallCmd.Flags().Bool("formulae", false, "Treat all named arguments as formulae.") + uninstallCmd.Flags().BoolP("help", "h", false, "Show this message.") + uninstallCmd.Flags().Bool("ignore-dependencies", false, "Don't fail uninstall , even if formula is a dependency") + uninstallCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet.") + uninstallCmd.Flags().BoolP("verbose", "v", false, "Make some output more verbose.") + uninstallCmd.Flags().Bool("zap", false, "Remove all files associated with a cask.") + rootCmd.AddCommand(uninstallCmd) + + carapace.Gen(uninstallCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + return action.ActionList(uninstallCmd).Invoke(c).Filter(c.Args).ToA() + }), + ) +} diff --git a/completers/brew_completer/cmd/update.go b/completers/brew_completer/cmd/update.go new file mode 100644 index 0000000000..38f27de581 --- /dev/null +++ b/completers/brew_completer/cmd/update.go @@ -0,0 +1,24 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var updateCmd = &cobra.Command{ + Use: "update", + Short: "Fetch the newest version of Homebrew and all formulae", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(updateCmd).Standalone() + + updateCmd.Flags().BoolP("debug", "d", false, "Display a trace of all shell commands as they are executed") + updateCmd.Flags().BoolP("force", "f", false, "Always do a slower, full update check") + updateCmd.Flags().BoolP("help", "h", false, "Show this message") + updateCmd.Flags().Bool("merge", false, "Use git merge to apply updates") + updateCmd.Flags().Bool("preinstall", false, "Run on auto-updates") + updateCmd.Flags().BoolP("verbose", "v", false, "Print the directories checked and git operations performed") + rootCmd.AddCommand(updateCmd) +} diff --git a/completers/brew_completer/cmd/upgrade.go b/completers/brew_completer/cmd/upgrade.go new file mode 100644 index 0000000000..42a2ce2746 --- /dev/null +++ b/completers/brew_completer/cmd/upgrade.go @@ -0,0 +1,81 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/completers/brew_completer/cmd/action" + "github.com/spf13/cobra" +) + +var upgradeCmd = &cobra.Command{ + Use: "upgrade", + Short: "Upgrade outdated casks and outdated, unpinned formulae", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(upgradeCmd).Standalone() + + upgradeCmd.Flags().String("appdir", "", "Target location for Applications") + upgradeCmd.Flags().String("audio-unit-plugindir", "", "Target location for Audio Unit Plugins") + upgradeCmd.Flags().Bool("binaries", false, "Disable/enable linking of helper executables") + upgradeCmd.Flags().BoolP("build-from-source", "s", false, "Compile formula from source even if a bottle is available") + upgradeCmd.Flags().Bool("cask", false, "Treat all named arguments as casks") + upgradeCmd.Flags().Bool("casks", false, "Treat all named arguments as casks") + upgradeCmd.Flags().String("colorpickerdir", "", "Target location for Color Pickers") + upgradeCmd.Flags().BoolP("debug", "d", false, "If brewing fails, open an interactive debugging session") + upgradeCmd.Flags().String("dictionarydir", "", "Target location for Dictionaries") + upgradeCmd.Flags().Bool("display-times", false, "Print install times for each package at the end of the run") + upgradeCmd.Flags().BoolP("dry-run", "n", false, "Show what would be upgraded") + upgradeCmd.Flags().Bool("fetch-HEAD", false, "Fetch the upstream repository to detect if the HEAD installation is outdated") + upgradeCmd.Flags().String("fontdir", "", "Target location for Fonts") + upgradeCmd.Flags().BoolP("force", "f", false, "Install formulae without checking for previously installed versions") + upgradeCmd.Flags().Bool("force-bottle", false, "Install from a bottle even if it would not normally be used") + upgradeCmd.Flags().Bool("formula", false, "Treat all named arguments as formulae") + upgradeCmd.Flags().Bool("formulae", false, "Treat all named arguments as formulae") + upgradeCmd.Flags().Bool("greedy", false, "Also include casks with auto_updates true") + upgradeCmd.Flags().Bool("greedy-auto-updates", false, "Also include casks with auto_updates true.") + upgradeCmd.Flags().Bool("greedy-latest", false, "Also include casks with version :latest.") + upgradeCmd.Flags().BoolP("help", "h", false, "Show this message.") + upgradeCmd.Flags().Bool("ignore-pinned", false, "Set a successful exit status even if pinned formulae are not upgraded") + upgradeCmd.Flags().String("input-methoddir", "", "Target location for Input Methods") + upgradeCmd.Flags().BoolP("interactive", "i", false, "Download and patch formula") + upgradeCmd.Flags().String("internet-plugindir", "", "Target location for Internet Plugins") + upgradeCmd.Flags().Bool("keep-tmp", false, "Retain the temporary files created during installation") + upgradeCmd.Flags().Bool("language", false, "Comma-separated list of language codes to prefer") + upgradeCmd.Flags().String("mdimporterdir", "", "Target location for Spotlight Plugins") + upgradeCmd.Flags().Bool("no-binaries", false, "Disable/enable linking of helper executables") + upgradeCmd.Flags().Bool("no-quarantine", false, "Disable/enable quarantining of downloads") + upgradeCmd.Flags().String("prefpanedir", "", "Target location for Preference Panes") + upgradeCmd.Flags().String("qlplugindir", "", "Target location for QuickLook Plugins") + upgradeCmd.Flags().Bool("quarantine", false, "Disable/enable quarantining of downloads") + upgradeCmd.Flags().BoolP("quiet", "q", false, "Make some output more quiet") + upgradeCmd.Flags().Bool("require-sha", false, "Require all casks to have a checksum.") + upgradeCmd.Flags().String("screen-saverdir", "", "Target location for Screen Savers") + upgradeCmd.Flags().String("servicedir", "", "Target location for Services") + upgradeCmd.Flags().Bool("skip-cask-deps", false, "Skip installing cask dependencies.") + upgradeCmd.Flags().BoolP("verbose", "v", false, "Print the verification and postinstall steps") + upgradeCmd.Flags().String("vst-plugindir", "", "Target location for VST Plugins") + upgradeCmd.Flags().String("vst3-plugindir", "", "Target location for VST3 Plugins") + rootCmd.AddCommand(upgradeCmd) + + carapace.Gen(upgradeCmd).FlagCompletion(carapace.ActionMap{ + "appdir": carapace.ActionDirectories(), + "audio-unit-plugindir": carapace.ActionDirectories(), + "colorpickerdir": carapace.ActionDirectories(), + "dictionarydir": carapace.ActionDirectories(), + "fontdir": carapace.ActionDirectories(), + "input-methoddir": carapace.ActionDirectories(), + "internet-plugindir": carapace.ActionDirectories(), + "mdimporterdir": carapace.ActionDirectories(), + "prefpanedir": carapace.ActionDirectories(), + "qlplugindir": carapace.ActionDirectories(), + "screen-saverdir": carapace.ActionDirectories(), + "servicedir": carapace.ActionDirectories(), + "vst-plugindir": carapace.ActionDirectories(), + "vst3-plugindir": carapace.ActionDirectories(), + }) + + carapace.Gen(upgradeCmd).PositionalAnyCompletion( + action.ActionList(upgradeCmd), + ) +} diff --git a/completers/brew_completer/main.go b/completers/brew_completer/main.go new file mode 100644 index 0000000000..f2313153c0 --- /dev/null +++ b/completers/brew_completer/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/rsteube/carapace-bin/completers/brew_completer/cmd" + +func main() { + cmd.Execute() +}