Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CommitCmd = &cobra.Command{ Use: "commit", Short: "Interactively commit using prompts", Long: `Do the commit. This command is disabled when you are using commit hooks`, Run: func(cmd *cobra.Command, args []string) { log.Debug("commit called") log.Debug(commitMsg) spin := ui.NewSpinner() spin.Run() existentHookFiles, err := pkg.HookFilesExistent() if err != nil { log.Fatalf("Error checking if hook files existent") } if len(existentHookFiles) > 0 { log.Infof("There are hook files existent for %s", existentHookFiles) log.Infof("Please use git commit command or remove the hooks with %s hooks rm", pkg.ProgramName) spin.Stop() return } gitmojis := pkg.GetGitmojis() spin.Stop() initialCommitValues := pkg.InitialCommitValues{Type: _type, Scope: scope, Desc: desc, Body: body} listSettings := ui.ListSettings{IsShowStatusBar: true, IsFilteringEnabled: true, Title: "Gitmojis"} selectedGitmoji := ui.ListRun(listSettings, gitmojis.Gitmojis) log.Debugf("selected gitmoji %s", selectedGitmoji) textInputsData := initialCommitValues.BuildTextInputsData(pkg.ConfigInstance) inputsRes := ui.TextInputsRun("please add", textInputsData) commitValues := pkg.CreateMessage(inputsRes, selectedGitmoji, initialCommitValues, pkg.ConfigInstance, isBreaking) log.Debugf("complete title: %s", commitValues.Title) if isDryRun { log.Infof("The commit title: %s", commitValues.Title) log.Infof("The commit body: %s", commitValues.Body) } else { pkg.ExecuteCommit(commitValues.Title, commitValues.Body, pkg.ConfigInstance) } }, }
CommitCmd represents the commit command
View Source
var ConfigCmd = &cobra.Command{ Use: "config", Short: fmt.Sprintf("Setup %s preferences.", pkg.ProgramName), Long: `Configure the cli. There are default options available which are overwritten by the local configuration file or a global configuration file within your OS config folder (use the info command to get the information where it is stored)`, Run: func(cmd *cobra.Command, args []string) { log.Debug("config called") config := pkg.ConfigInstance autoAdd := runConfigConfirmationPrompt("Enable automatic 'git add .'", config.AutoAdd) autoSign := runConfigConfirmationPrompt("Automatically sign commits (add '-S' flag)", config.AutoSign) emojiFormat := runEmojiSelectionPrompt("Select how emojis should be used in commits. For a comparison please visit https://gitmoji.dev/specification") scopePrompt := runConfigConfirmationPrompt("Enable scope prompt", config.ScopePrompt) bodyPrompt := runConfigConfirmationPrompt("Enable body prompt", config.BodyPrompt) capitalizeTitle := runConfigConfirmationPrompt("Capitalize title", config.CapitalizeTitle) gitmojisApiUrl := runGitmojiUrlInputPrompt("Set gitmojis api url", "https://gitmoji.dev/api/gitmojis") config = pkg.Config{AutoAdd: autoAdd, AutoSign: autoSign, EmojiFormat: emojiFormat, ScopePrompt: scopePrompt, CapitalizeTitle: capitalizeTitle, GitmojisUrl: gitmojisApiUrl, BodyPrompt: bodyPrompt} pkg.UpdateConfig(config, isConfigGlobal) }, }
View Source
var HooksCmd = &cobra.Command{ Use: "hooks", Short: fmt.Sprintf("Manage %s commit hooks", pkg.ProgramName), Long: `Manage git hooks for the cli`, Args: func(cmd *cobra.Command, args []string) error { log.Debugf("args: %v", args) if hook { hookCommitMessageFile = args[0] } return nil }, Run: func(cmd *cobra.Command, args []string) { log.Debug("hooks called") if hook { hookCommit() } }, }
View Source
var HooksInitCmd = &cobra.Command{ Use: "init", Short: fmt.Sprintf("initialize git hooks for %s", pkg.ProgramName), Long: `Install the commit hooks into the local .git/hooks/ directory.`, Run: func(cmd *cobra.Command, args []string) { log.Debug("hooks init called") err := pkg.CreateAllHookFiles() if err != nil { log.Error(err) return } }, }
View Source
var HooksRemoveCmd = &cobra.Command{ Use: "rm", Short: fmt.Sprintf("remove git hooks for %s", pkg.ProgramName), Long: `Delete the commit hooks which are created by the cli`, Run: func(cmd *cobra.Command, args []string) { log.Debug("hooks rm called") err := pkg.RemoveAllHookFiles() if err != nil { log.Error(err) return } }, }
View Source
var InfoCmd = &cobra.Command{ Use: "info", Short: "Get some relevant information", Long: `Get some information like config or cache directory on your OS where the cli is writing configuration or cache.`, Run: func(cmd *cobra.Command, args []string) { globalConfigDir, _ := utils.GetGlobalConfigDir(pkg.ProgramName) cacheDir, _ := utils.GetCacheDir(pkg.ProgramName) log.Debug("info called") log.Infof("program name: %s", pkg.ProgramName) log.Infof("version: %s", pkg.Version) log.Info("It is possible to store the configuration within the repository or globally") log.Infof("The global config path: %s", globalConfigDir) log.Infof("The gitmoji infomration is queried from the internet at the gitmoji defined in the config %s", pkg.ConfigInstance.GitmojisUrl) log.Info("and cached") log.Infof("Gitmoji cache dir: %s", cacheDir) }, }
View Source
var ListCmd = &cobra.Command{ Use: "list", Short: "List all the available gitmojis", Long: fmt.Sprintf(`The list is queried from the api %s.`, pkg.DefaultGitmojiApiUrl), Run: func(cmd *cobra.Command, args []string) { log.Debug("list called") spin := ui.NewSpinner() spin.Run() gitmojis := pkg.GetGitmojis() spin.Stop() listSettings := ui.ListSettings{Title: "Gitmojis", IsShowStatusBar: true, IsFilteringEnabled: true} selectedGitmoji := ui.ListRun(listSettings, gitmojis.Gitmojis) log.Debugf("selected %s", selectedGitmoji) }, }
ListCmd represents the list command
View Source
var RootCmd = &cobra.Command{ Use: pkg.ProgramName, Version: pkg.Version, Short: "Cli to help managing gitmoji commit messages", Long: fmt.Sprintf(`See %s for more information about Gitmoji`, pkg.DefaultGitmojiUrl), }
View Source
var UpdateGitmojisCmd = &cobra.Command{ Use: "gitmojis", Short: fmt.Sprintf("update the local gitmoji database %s", pkg.ProgramName), Long: fmt.Sprintf(`Update the gitmojis local cache from %s.`, pkg.DefaultGitmojiApiUrl), Run: func(cmd *cobra.Command, args []string) { log.Debug("update gitmojis called") gitmojis := pkg.GetGitmojis() pkg.CacheGitmojis(gitmojis) }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.