cli

package
v0.0.0-...-b7a57f2 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthCmd = &cobra.Command{
	Use:   "auth",
	Short: "Log in to a bob server",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		err := cmd.Help()
		errz.Fatal(err)
	},
}
View Source
var AuthContextCreateCmd = &cobra.Command{
	Use:   "init",
	Short: "Initialize a authentication context",
	Long: `Initialize a authentication context  

Example:
  bob auth init --token=xxx              (default context)
  bob auth init contextName --token=xxx
`,
	Run: func(cmd *cobra.Command, args []string) {
		name := defaultContext
		if len(args) == 1 {
			name = args[0]
		}

		token, err := cmd.Flags().GetString("token")
		if err != nil {
			boblog.Log.UserError(errors.WithMessage(err, "failed to parse token"))
			return
		}

		if token == "" {
			boblog.Log.UserError(fmt.Errorf("token missing"))
			return
		}

		err = runAuthContextCreate(name, token)
		if errors.As(err, &usererror.Err) {
			boblog.Log.UserError(err)
			return
		} else {
			errz.Fatal(err)
		}

		err = runAuthContextSwitch(name)
		if errors.As(err, &usererror.Err) {
			boblog.Log.UserError(err)
		} else {
			errz.Fatal(err)
		}
	},
}
View Source
var AuthContextDeleteCmd = &cobra.Command{
	Use:   "rm",
	Short: "Removes an authentication context",
	Long: `Removes an authentication context  

Example:
  bob auth rm contextName
`,

	Args: cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		var name string
		if len(args) == 1 {
			name = args[0]
		}

		if name == "" {
			err := cmd.Help()
			errz.Fatal(err)
			return
		}

		err := runAuthContextDelete(name)
		if errors.As(err, &usererror.Err) {
			boblog.Log.UserError(err)
		} else {
			errz.Fatal(err)
		}
	},
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		contextNames, err := getAuthContextNames()
		if err != nil {
			return nil, cobra.ShellCompDirectiveError
		}

		return contextNames, cobra.ShellCompDirectiveDefault
	},
}
View Source
var AuthContextListCmd = &cobra.Command{
	Use:   "ls",
	Short: "Lists authentication contexts",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		err := runAuthContextList()
		if errors.As(err, &usererror.Err) {
			boblog.Log.UserError(err)
		} else {
			errz.Fatal(err)
		}
	},
}
View Source
var AuthContextSwitchCmd = &cobra.Command{
	Use:   "switch",
	Short: "Switches to a different authentication context",
	Long: `Switches to a different authentication context

Example:
  bob auth switch contextName
`,
	Args: cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		var name string
		if len(args) == 1 {
			name = args[0]
		}

		if name == "" {
			err := cmd.Help()
			errz.Fatal(err)
			return
		}

		err := runAuthContextSwitch(name)
		if errors.As(err, &usererror.Err) {
			boblog.Log.UserError(err)
		} else {
			errz.Fatal(err)
		}
	},
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		contextNames, err := getAuthContextNames()
		if err != nil {
			return nil, cobra.ShellCompDirectiveError
		}

		return contextNames, cobra.ShellCompDirectiveDefault
	},
}
View Source
var AuthContextUpdateCmd = &cobra.Command{
	Use:   "update",
	Short: "Updates an authentication context's token",
	Long: `Updates an authentication context's token  

Example:
  bob auth update --token=xxx              (default context)
  bob auth update contextName --token=xxx
`,
	Run: func(cmd *cobra.Command, args []string) {
		name := defaultContext
		if len(args) == 1 {
			name = args[0]
		}

		token, err := cmd.Flags().GetString("token")
		if err != nil {
			boblog.Log.UserError(errors.WithMessage(err, "failed to parse token"))
			return
		}

		if token == "" {
			boblog.Log.UserError(fmt.Errorf("token missing "))
			return
		}

		err = runAuthContextUpdate(name, token)
		if errors.As(err, &usererror.Err) {
			boblog.Log.UserError(err)
		} else {
			errz.Fatal(err)
		}
	},
}
View Source
var CmdClone = &cobra.Command{
	Use:   "clone",
	Short: "Clone a bob workspace and child repositorys",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		failFast, err := cmd.Flags().GetBool("fail-fast")
		errz.Fatal(err)
		https, err := cmd.Flags().GetBool("https")
		errz.Fatal(err)
		ssh, err := cmd.Flags().GetBool("ssh")
		errz.Fatal(err)

		if ssh && https {
			fmt.Printf("%s\n", aurora.Red("You can only use one of --ssh or --https"))
			os.Exit(0)
		}

		var protocol string
		if ssh {
			protocol = "ssh"
		} else if https {
			protocol = "https"
		}

		var url string
		if len(args) > 0 {
			url = args[0]
		}
		runClone(url, failFast, protocol)
	},
}
View Source
var CmdGit = &cobra.Command{
	Use:   "git",
	Short: "Run git cmds on all child repos",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		err := cmd.Help()
		errz.Fatal(err)
	},
}
View Source
var CmdGitAdd = &cobra.Command{
	Use:   "add",
	Short: "Run git add on all child repos",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		runGitAdd(args...)
	},
}
View Source
var CmdGitCommit = &cobra.Command{
	Use:   "commit",
	Short: "Run git commit on all child repos using the given message",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		message, _ := cmd.Flags().GetString("message")
		runGitCommit(message)
	},
}
View Source
var CmdGitStatus = &cobra.Command{
	Use:   "status",
	Short: "Run git status on all child repos",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		runGitStatus()
	},
}
View Source
var GlobalConfig *config // nolint:varcheck, unused

Config the global config object

Functions

func Execute

func Execute() error

Types

This section is empty.

Jump to

Keyboard shortcuts

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