settings

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrintCommand = cli.Command{
	Name:  "print",
	Usage: "List Granted Settings",
	Action: func(c *cli.Context) error {
		cfg, err := config.Load()
		if err != nil {
			return err
		}
		data := [][]string{
			{"logging verbosity", debug.CliVerbosity.String()},
			{"update-checker-api-url", c.String("update-checker-api-url")},
		}

		for k, v := range structs.Map(cfg) {
			data = append(data, []string{k, fmt.Sprint(v)})
		}

		table := tablewriter.NewWriter(color.Error)
		table.SetHeader([]string{"SETTING", "VALUE"})
		table.SetAutoWrapText(false)
		table.SetAutoFormatHeaders(true)
		table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
		table.SetAlignment(tablewriter.ALIGN_LEFT)
		table.SetCenterSeparator("")
		table.SetColumnSeparator("")
		table.SetRowSeparator("")
		table.SetRowLine(true)
		table.SetHeaderLine(false)
		table.SetBorder(false)
		table.SetTablePadding("\t")
		table.SetNoWhiteSpace(true)
		table.AppendBulk(data)
		table.Render()
		return nil
	},
}
View Source
var ProfileOrderingCommand = cli.Command{
	Name:        "profile-order",
	Usage:       "Update profile ordering when assuming",
	Subcommands: []*cli.Command{&SetProfileOrderingCommand},
	Action: func(c *cli.Context) error {
		cfg, err := config.Load()
		if err != nil {
			return err
		}

		green := color.New(color.FgGreen)

		green.Fprintln(color.Error, "Current profile ordering method: ", cfg.Ordering)
		return nil

	},
}
View Source
var SetProfileOrderingCommand = cli.Command{
	Name:  "set",
	Usage: "Sets the method of ordering IAM profiles in the assume method",
	Action: func(c *cli.Context) error {
		cfg, err := config.Load()
		if err != nil {
			return err
		}
		withStdio := survey.WithStdio(os.Stdin, os.Stderr, os.Stderr)
		in := survey.Select{
			Message: "Select filter type",
			Options: []string{"Frecency", "Alphabetical"},
		}
		var selection string
		fmt.Fprintln(color.Error)
		err = testable.AskOne(&in, &selection, withStdio)
		if err != nil {
			return err
		}

		cfg.Ordering = selection
		err = cfg.Save()
		if err != nil {
			return err
		}

		green := color.New(color.FgGreen)

		green.Fprintln(color.Error, "Set profile ordering to: ", selection)
		return nil

	},
}
View Source
var SettingsCommand = cli.Command{
	Name:        "settings",
	Usage:       "Manage Granted settings",
	Subcommands: []*cli.Command{&PrintCommand, &ProfileOrderingCommand},
	Action:      PrintCommand.Action,
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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