cmd

package
v0.6.14 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShellCmd = &cobra.Command{
	Use:   "bit",
	Short: "Bit is a Git CLI that predicts what you want to do",
	Long:  `v0.6.14`,
	Run: func(cmd *cobra.Command, args []string) {
		completerSuggestionMap, bitCmdMap := CreateSuggestionMap(cmd)

		resp := SuggestionPrompt("> bit ", shellCommandCompleter(completerSuggestionMap))
		subCommand := resp
		if subCommand == "" {
			return
		}
		if strings.Index(resp, " ") > 0 {
			subCommand = subCommand[0:strings.Index(resp, " ")]
		}
		parsedArgs, err := parseCommandLine(resp)
		if err != nil {
			log.Debug().Err(err)
			return
		}
		if bitCmdMap[subCommand] == nil {
			yes := GitCommandsPromptUsed(parsedArgs, completerSuggestionMap)
			if yes {
				return
			}
			RunGitCommandWithArgs(parsedArgs)
			return
		}

		cmd.SetArgs(parsedArgs)
		cmd.Execute()
	},
}

ShellCmd represents the base command when called without any subcommands

Functions

func AddCommandToShellHistory added in v0.3.13

func AddCommandToShellHistory(cmd string, args []string)

func AllBitAndGitSubCommands added in v0.3.13

func AllBitAndGitSubCommands(rootCmd *cobra.Command) (cc []*cobra.Command)

func AllBitSubCommands added in v0.3.13

func AllBitSubCommands(rootCmd *cobra.Command) ([]*cobra.Command, map[string]*cobra.Command)

func AllGitAliases added in v0.3.14

func AllGitAliases() (cc []*cobra.Command)

func AllGitSubCommands added in v0.3.13

func AllGitSubCommands() []*cobra.Command

func AskConfirm added in v0.4.9

func AskConfirm(q string) bool

func AskMultiLine added in v0.6.2

func AskMultiLine(q string) string

func BranchListSuggestions added in v0.3.13

func BranchListSuggestions() []prompt.Suggest

func CloudBranchExists added in v0.3.13

func CloudBranchExists() bool

func CobraCommandToSuggestions added in v0.3.13

func CobraCommandToSuggestions(cmds []*cobra.Command) []prompt.Suggest

func CommonCommandsList added in v0.3.14

func CommonCommandsList() []*cobra.Command

func CreateSuggestionMap added in v0.4.17

func CreateSuggestionMap(cmd *cobra.Command) (map[string][]prompt.Suggest, map[string]*cobra.Command)

func CurrentBranch added in v0.3.13

func CurrentBranch() string

func Execute

func Execute()

Execute adds all child commands to the shell command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the ShellCmd.

func Find added in v0.6.14

func Find(slice []string, val string) int

func FlagSuggestionsForCommand added in v0.3.13

func FlagSuggestionsForCommand(gitSubCmd string, flagtype string) []prompt.Suggest

func GenBumpedSemVersion added in v0.3.13

func GenBumpedSemVersion() string

func GitAddSuggestions added in v0.3.13

func GitAddSuggestions() []prompt.Suggest

func GitCommandsPromptUsed added in v0.4.17

func GitCommandsPromptUsed(args []string, suggestionMap map[string][]prompt.Suggest) bool

func GitResetSuggestions added in v0.3.16

func GitResetSuggestions() []prompt.Suggest

func HandleExit added in v0.4.4

func HandleExit()

func IsAheadOfCurrent added in v0.3.13

func IsAheadOfCurrent() bool

func IsBehindCurrent added in v0.3.13

func IsBehindCurrent() bool

func IsDiverged added in v0.3.13

func IsDiverged() bool

func IsGitRepo added in v0.4.3

func IsGitRepo() bool

func MostRecentCommonAncestorCommit added in v0.3.17

func MostRecentCommonAncestorCommit(branchA, branchB string) string

func NothingToCommit added in v0.3.13

func NothingToCommit() bool

func PrintGitVersion added in v0.6.6

func PrintGitVersion()

func RunGitCommandWithArgs added in v0.4.1

func RunGitCommandWithArgs(args []string)

func RunInTerminalWithColor added in v0.4.1

func RunInTerminalWithColor(cmdName string, args []string) error

func RunInTerminalWithColorInDir added in v0.4.14

func RunInTerminalWithColorInDir(cmdName string, dir string, args []string) error

func RunScriptWithString added in v0.3.13

func RunScriptWithString(path string, script string, args ...string)

func StashList added in v0.3.13

func StashList() []string

func StashableChanges added in v0.3.13

func StashableChanges() bool

func SuggestionPrompt added in v0.3.13

func SuggestionPrompt(prefix string, completer func(d prompt.Document) []prompt.Suggest) string

Types

type Branch added in v0.3.13

type Branch struct {
	Author       string
	Name         string
	RelativeDate string
	AbsoluteDate string
}

func BranchList added in v0.3.13

func BranchList() []Branch

type Exit added in v0.4.4

type Exit int

type FileChange added in v0.3.13

type FileChange struct {
	Name   string
	Status string
}

func FileChangesList added in v0.3.13

func FileChangesList() []FileChange

Jump to

Keyboard shortcuts

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