Documentation ¶
Overview ¶
Package cli provides the interface for the command-line.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AutoCompleteCommand = cli.Command{ Name: "autocomplete", Aliases: []string{"ac"}, Usage: "Configure shell autocompletion", UsageText: "abra autocomplete <shell> [options]", Description: `Set up shell auto-completion. Supported shells are: bash, fish, fizsh & zsh.`, HideHelp: true, Action: func(ctx context.Context, cmd *cli.Command) error { shellType := cmd.Args().First() if shellType == "" { internal.ShowSubcommandHelpAndError(cmd, errors.New("no shell provided")) } supportedShells := map[string]bool{ "bash": true, "zsh": true, "fizsh": true, "fish": true, } if _, ok := supportedShells[shellType]; !ok { log.Fatalf("%s is not a supported shell right now, sorry", shellType) } if shellType == "fizsh" { shellType = "zsh" } autocompletionDir := path.Join(config.ABRA_DIR, "autocompletion") if err := os.Mkdir(autocompletionDir, 0764); err != nil { if !os.IsExist(err) { log.Fatal(err) } log.Debugf("%s already created", autocompletionDir) } autocompletionFile := path.Join(config.ABRA_DIR, "autocompletion", shellType) if _, err := os.Stat(autocompletionFile); err != nil && os.IsNotExist(err) { url := fmt.Sprintf("https://git.coopcloud.tech/coop-cloud/abra/raw/branch/main/scripts/autocomplete/%s", shellType) log.Infof("fetching %s", url) if err := web.GetFile(autocompletionFile, url); err != nil { log.Fatal(err) } } switch shellType { case "bash": fmt.Println(fmt.Sprintf(` # run the following commands once to install auto-completion sudo mkdir -p /etc/bash_completion.d/ sudo cp %s /etc/bash_completion.d/abra echo "source /etc/bash_completion.d/abra" >> ~/.bashrc source /etc/bash_completion.d/abra # To test, run the following: "abra app <hit tab key>" - you should see command completion! `, autocompletionFile)) case "zsh": fmt.Println(fmt.Sprintf(` # run the following commands to once install auto-completion sudo mkdir -p /etc/zsh/completion.d/ sudo cp %s /etc/zsh/completion.d/abra echo "PROG=abra\n_CLI_ZSH_AUTOCOMPLETE_HACK=1\nsource /etc/zsh/completion.d/abra" >> ~/.zshrc source /etc/zsh/completion.d/abra # to test, run the following: "abra app <hit tab key>" - you should see command completion! `, autocompletionFile)) case "fish": fmt.Println(fmt.Sprintf(` # run the following commands once to install auto-completion sudo mkdir -p /etc/fish/completions sudo cp %s /etc/fish/completions/abra echo "source /etc/fish/completions/abra" >> ~/.config/fish/config.fish source /etc/fish/completions/abra # to test, run the following: "abra app <hit tab key>" - you should see command completion! `, autocompletionFile)) } return nil }, }
AutoCompleteCommand helps people set up auto-complete in their shells
View Source
var UpgradeCommand = cli.Command{ Name: "upgrade", Aliases: []string{"u"}, Usage: "Upgrade abra", UsageText: "abra upgrade [options]", Description: `Upgrade abra in-place with the latest stable or release candidate. Use "--rc/-r" to install the latest release candidate. Please bear in mind that it may contain absolutely catastrophic deal-breaker bugs. Thank you very much for the testing efforts 💗`, Flags: []cli.Flag{internal.RCFlag}, HideHelp: true, Action: func(ctx context.Context, cmd *cli.Command) error { mainURL := "https://install.abra.coopcloud.tech" c := exec.Command("bash", "-c", fmt.Sprintf("wget -q -O- %s | bash", mainURL)) if internal.RC { releaseCandidateURL := "https://git.coopcloud.tech/coop-cloud/abra/raw/branch/main/scripts/installer/installer" c = exec.Command("bash", "-c", fmt.Sprintf("wget -q -O- %s | bash -s -- --rc", releaseCandidateURL)) } log.Debugf("attempting to run %s", c) if err := internal.RunCmd(c); err != nil { log.Fatal(err) } return nil }, }
UpgradeCommand upgrades abra in-place.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.