granted

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CompletionCommand = cli.Command{
	Name:  "completion",
	Usage: "Add autocomplete to your granted cli installation",
	Flags: flags,
	Action: func(c *cli.Context) error {

		if c.String("shell") == "fish" {

			assumeApp := assume.GetCliApp()

			if build.Version == "dev" {
				fmt.Printf("⚙️  Generating commands for dgranted/dassume\n")
				c.App.Name = "dgranted"
				assumeApp.Name = "dassume"
			} else {
				c.App.Name = "granted"
				assumeApp.Name = "assume"
			}

			grantedAppOutput, _ := c.App.ToFishCompletion()
			assumeAppOutput, _ := assumeApp.ToFishCompletion()
			combinedOutput := fmt.Sprintf("%s\n%s", grantedAppOutput, assumeAppOutput)

			user, _ := user.Current()

			executableDir := user.HomeDir + "/.config/fish/completions/granted_completer_fish.fish"

			err := os.WriteFile(executableDir, []byte(combinedOutput), 0600)
			if err != nil {
				fmt.Fprintln(os.Stderr, "Something went wrong when saving fish autocompletions: "+err.Error())
			}

			green := color.New(color.FgGreen)

			green.Fprintln(os.Stderr, "[✔] Fish autocompletions generated successfully ")
			fmt.Fprintln(os.Stderr, "To use these completions please run the executable:")
			fmt.Fprintln(os.Stderr, "source "+executableDir)

		} else {
			fmt.Fprintln(os.Stderr, "To install completions for other shells like zsh, bash, please see our docs:")
			fmt.Fprintln(os.Stderr, "https://granted.dev/autocompletion")

		}

		return nil
	},

	Description: "To install completions for other shells like zsh, bash, please see our docs:\nhttps://granted.dev/autocompletion\n",
}
View Source
var DefaultBrowserCommand = cli.Command{
	Name:        "browser",
	Usage:       "View the web browser that Granted uses to open cloud consoles",
	Subcommands: []*cli.Command{&SetBrowserCommand},
	Action: func(c *cli.Context) error {

		conf, err := config.Load()
		if err != nil {
			return err
		}
		fmt.Fprintf(os.Stderr, "Granted is using %s. To change this run `granted browser set`.\n", conf.DefaultBrowser)

		return nil
	},
}
View Source
var SetBrowserCommand = cli.Command{
	Name:  "set",
	Usage: "Change the web browser that Granted uses to open cloud consoles",
	Action: func(c *cli.Context) error {
		outcome, err := browsers.HandleManualBrowserSelection()
		if err != nil {
			return err
		}

		return browsers.ConfigureBrowserSelection(outcome)
	},
}

Functions

func GetCliApp

func GetCliApp() *cli.App

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL