Documentation

Overview

    Package main is complete tool for the go command line

    Index

    Constants

    This section is empty.

    Variables

    View Source
    var BitCmd = &cobra.Command{
    	Use:   "bit",
    	Short: "Bit is a Git CLI that predicts what you want to do",
    	Long:  ``,
    	Run: func(cmd *cobra.Command, args []string) {
    		suggestionTree, bitCmdMap := CreateSuggestionMap(cmd)
    
    		resp := SuggestionPrompt("> bit ", shellCommandCompleter(suggestionTree))
    		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).Send()
    			return
    		}
    		if bitCmdMap[subCommand] == nil {
    			yes := HijackGitCommandOccurred(parsedArgs, suggestionTree, cmd.Version)
    			if yes {
    				return
    			}
    			RunGitCommandWithArgs(parsedArgs)
    			return
    		}
    
    		cmd.SetArgs(parsedArgs)
    		cmd.Execute()
    	},
    }

      BitCmd represents the base command when called without any subcommands

      View Source
      var DefaultTheme = PromptTheme{
      	PrefixTextColor:             prompt.Yellow,
      	SelectedSuggestionBGColor:   prompt.Yellow,
      	SuggestionBGColor:           prompt.Yellow,
      	SuggestionTextColor:         prompt.DarkGray,
      	SelectedSuggestionTextColor: prompt.Blue,
      	DescriptionBGColor:          prompt.Black,
      	DescriptionTextColor:        prompt.White,
      }
      View Source
      var InvertedTheme = PromptTheme{
      	PrefixTextColor:             prompt.Blue,
      	SelectedSuggestionBGColor:   prompt.LightGray,
      	SelectedSuggestionTextColor: prompt.White,
      	SuggestionBGColor:           prompt.Blue,
      	SuggestionTextColor:         prompt.White,
      	DescriptionBGColor:          prompt.LightGray,
      	DescriptionTextColor:        prompt.Black,
      }
      View Source
      var MonochromeTheme = PromptTheme{}

      Functions

      func AddCommandToShellHistory

      func AddCommandToShellHistory(cmd string, args []string)

      func AllBitAndGitSubCommands

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

      func AllBitSubCommands

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

      func AllGitAliases

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

      func AllGitSubCommands

      func AllGitSubCommands() map[string]*complete.CompTree

      func AskConfirm

      func AskConfirm(q string) bool

      func AskMultiLine

      func AskMultiLine(q string) string

      func Bitcomplete

      func Bitcomplete()

      func BranchListSuggestions

      func BranchListSuggestions() []complete.Suggestion

      func CloudBranchExists

      func CloudBranchExists() bool

      func CobraCommandToDesc

      func CobraCommandToDesc(cmds []*cobra.Command) []string

      func CobraCommandToName

      func CobraCommandToName(cmds []*cobra.Command) []string

      func CobraCommandToSuggestions

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

      func CommonCommandsList

      func CommonCommandsList() []*cobra.Command

      func CreateSuggestionMap

      func CreateSuggestionMap(cmd *cobra.Command) (*complete.CompTree, map[string]*cobra.Command)

      func CurrentBranch

      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 BitCmd.

        func Find

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

        func FlagSuggestionsForCommand

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

        func GHCliExistsAndLoggedIn

        func GHCliExistsAndLoggedIn() bool

        func GenBumpedSemVersion

        func GenBumpedSemVersion(out string) (string, error)

        func GetVersion

        func GetVersion() string

        func GitAddSuggestions

        func GitAddSuggestions() []complete.Suggestion

        func GitHubPRSuggestions

        func GitHubPRSuggestions(prefix string) func(prefix string) []complete.Suggestion

        func GitResetSuggestions

        func GitResetSuggestions() []prompt.Suggest

        func GitmojiSuggestions

        func GitmojiSuggestions() []complete.Suggestion

        func HandleExit

        func HandleExit()

        func HijackGitCommandOccurred

        func HijackGitCommandOccurred(args []string, suggestionMap *complete.CompTree, version string) bool

        func IsAheadOfCurrent

        func IsAheadOfCurrent() bool

        func IsBehindCurrent

        func IsBehindCurrent() bool

        func IsDiverged

        func IsDiverged() bool

        func IsGitRepo

        func IsGitRepo() bool

        func MostRecentCommonAncestorCommit

        func MostRecentCommonAncestorCommit(branchA, branchB string) string

        func NothingToCommit

        func NothingToCommit() bool

        func PrintGitVersion

        func PrintGitVersion()

        func RunGitCommandWithArgs

        func RunGitCommandWithArgs(args []string)

        func RunInTerminalWithColor

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

        func RunInTerminalWithColorInDir

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

        func RunScriptWithString

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

        func StashList

        func StashList() []string

        func StashableChanges

        func StashableChanges() bool

        func SuggestionPrompt

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

        Types

        type Branch

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

        func BranchList

        func BranchList() []*Branch

        type Exit

        type Exit int

        type FileChange

        type FileChange struct {
        	Name   string
        	Status string
        }

        func FileChangesList

        func FileChangesList() []FileChange

        type Gitmoji

        type Gitmoji struct {
        	Emoji       string `json:"emoji"`
        	Entity      string `json:"entity"`
        	Code        string `json:"code"`
        	Description string `json:"description"`
        	Name        string `json:"name"`
        }

        type PromptTheme

        type PromptTheme struct {
        	PrefixTextColor             prompt.Color
        	SelectedSuggestionBGColor   prompt.Color
        	SuggestionBGColor           prompt.Color
        	SuggestionTextColor         prompt.Color
        	SelectedSuggestionTextColor prompt.Color
        	DescriptionBGColor          prompt.Color
        	DescriptionTextColor        prompt.Color
        }

        type PullRequest

        type PullRequest struct {
        	Title        string
        	Number       int
        	AuthorBranch string
        	State        string
        }

        func ListGHPullRequests

        func ListGHPullRequests() []*PullRequest