Documentation ¶
Index ¶
Constants ¶
View Source
const Version = "1.9.0"
Version constant
Variables ¶
View Source
var AddCmd = &cobra.Command{
Use: "add",
Short: "Add a new authentication configuration",
Long: `Add a new authentication configuration`}
AddCmd is the took add command
View Source
var DeleteCmd = &cobra.Command{ Use: "delete", Short: "Delete an authentication configuration", Long: `Delete an authentication configuration`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { InitConfig() cfg.DecryptUserConfig(cfg.UserCfgFile) _, ok := cfg.UserCfg.Remotes[args[0]] if !ok { log.Fatalf("%s not found", args[0]) } if !forceDelete { answer := cfg.Ask(fmt.Sprintf("Delete %s (y/N): ", args[0])) if answer != "y" && answer != "Y" { return } } delete(cfg.UserCfg.Remotes, args[0]) WriteUserConfig() }}
DeleteCmd is the took delete command
View Source
var ModCmd = &cobra.Command{
Use: "update",
Short: "Update an existing configuration",
Long: "Update an existing configuration"}
ModCmd is the took update commdand
View Source
var RootCmd = &cobra.Command{
Use: "took",
Short: "Authentication token manager",
Long: `Manage tokens.`}
RootCmd represents the base command when called without any subcommands
View Source
var TokenCmd = &cobra.Command{ Use: `token [flags] config [username] Get a token for the configuration "config" for "username".`, Short: "Get a token", Long: `Get a token for a config, renew if necessary`, Args: cobra.RangeArgs(1, 3), Run: func(cmd *cobra.Command, args []string) { InitConfig() cfg.DecryptUserConfig(cfg.UserCfgFile) userRemote, uok := cfg.UserCfg.Remotes[args[0]] commonRemote, cok := cfg.CommonCfg.Remotes[args[0]] if !uok && !cok { log.Fatalf("Cannot find %s\n", args[0]) } t := userRemote.Type if len(t) == 0 { t = commonRemote.Type } if len(t) == 0 { log.Fatalf("Invalid configuration: no type for %s", args[0]) } protocol := proto.Get(t) if protocol == nil { fmt.Printf("Cannot find protocol %s\n", t) os.Exit(1) } protocol.SetCfg(userRemote, commonRemote) opt := proto.UseDefault if forceNew { opt = proto.UseReAuth } else if forceRenew { opt = proto.UseRefresh } out := proto.OutputToken if writeHeader { out = proto.OutputHeader } userName := "" password := "" if len(args) > 1 { userName = args[1] } if len(args) > 2 { password = args[2] } s, data, err := protocol.GetToken(proto.TokenRequest{Refresh: opt, Out: out, Username: userName, Password: password}) if err != nil { fmt.Printf("%s\n", err) os.Exit(1) } fmt.Println(s) cfg.UserCfg.Remotes[args[0]] = cfg.Remote{Type: userRemote.Type, Configuration: userRemote.Configuration, Data: data} WriteUserConfig() }}
TokenCmd is the took token command
View Source
var VerCmd = &cobra.Command{ Use: "version", Short: "Show took version", Long: `Show took version`, Run: func(cmd *cobra.Command, args []string) { fmt.Println(Version) }}
VerCmd is the took version command
Functions ¶
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the RootCmd.
func InitConfig ¶ added in v1.8.6
func InitConfig()
InitConfig reads in config file and ENV variables if set.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.