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 } config, err := pkg.GetCurrentConfig() if err != nil { log.Fatalf("get current config issue, %s", err) } gitmojis := pkg.GetGitmojis(config) defaultTypes := pkg.DefaultCommitTypes() initialCommitValues := pkg.BuildInitialCommitValues(_type, scope, desc, body, commitMsg) listSettingsGitmojis := ui.ListSettings{IsShowStatusBar: true, IsFilteringEnabled: true, Title: "Gitmojis"} listSettingsCommitTypes := ui.ListSettings{Title: "Commit types", IsShowStatusBar: true, IsFilteringEnabled: true} spin.Stop() selectedGitmoji := ui.ListRun(listSettingsGitmojis, gitmojis.Gitmojis) log.Debugf("selected gitmoji %s", selectedGitmoji) selectedDefaultType := ui.ListRun(listSettingsCommitTypes, defaultTypes) log.Debugf("selected %s", selectedDefaultType) initialCommitValues.Type = selectedDefaultType.Type textInputsData := initialCommitValues.BuildTextInputsData(config) inputsRes := ui.TextInputsRun("please add", textInputsData) commitValues := pkg.CreateMessage(inputsRes, selectedGitmoji, initialCommitValues, config, 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, config) } }, }
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, err := pkg.GetCurrentConfig() if err != nil { log.Fatalf("get current config issue, %s", err) } 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) debug := runConfigConfirmationPrompt("debug mode", config.Debug) 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, Debug: debug, } pkg.UpdateConfig(config, isConfigGlobal) }, }
View Source
var GlamourTheme = ansi.StyleConfig{ Document: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ BlockPrefix: "\n", BlockSuffix: "\n", }, Margin: uintPtr(margin), }, Heading: ansi.StyleBlock{ StylePrimitive: ansi.StylePrimitive{ BlockSuffix: "\n", Color: stringPtr("99"), Bold: boolPtr(true), }, }, Item: ansi.StylePrimitive{Prefix: "· "}, Emph: ansi.StylePrimitive{Color: stringPtr(brightBlack)}, Strong: ansi.StylePrimitive{Bold: boolPtr(true)}, Link: ansi.StylePrimitive{Color: stringPtr("42"), Underline: boolPtr(true)}, LinkText: ansi.StylePrimitive{Color: stringPtr("207")}, Code: ansi.StyleBlock{StylePrimitive: ansi.StylePrimitive{Color: stringPtr("204")}}, }
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") log.Debugf("run: %v", args) if hook { hookCommit(hookCommitMessageFile) } }, }
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) { config, err := pkg.GetCurrentConfig() if err != nil { log.Fatalf("error while getting config %s", err) } 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 information is queried from the internet at the gitmoji defined in the config %s", config.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") }, }
View Source
var ListCommitTypesCmd = &cobra.Command{ Use: "commit-types", Short: "List all the available commit types", Long: "The list from conventional commits is used", Run: func(cmd *cobra.Command, args []string) { log.Debug("list commit-types called") spin := ui.NewSpinner() spin.Run() defaultTypes := pkg.DefaultCommitTypes() spin.Stop() listSettings := ui.ListSettings{Title: "Commit types", IsShowStatusBar: true, IsFilteringEnabled: true} selectedDefaultType := ui.ListRun(listSettings, defaultTypes) log.Debugf("selected %s", selectedDefaultType) }, }
View Source
var ListGitmojisCmd = &cobra.Command{ Use: "gitmojis", 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 gitmojis called") spin := ui.NewSpinner() spin.Run() config, err := pkg.GetCurrentConfig() if err != nil { log.Fatalf("get current config issue, %s", err) } gitmojis := pkg.GetGitmojis(config) spin.Stop() listSettings := ui.ListSettings{Title: "Gitmojis", IsShowStatusBar: true, IsFilteringEnabled: true} selectedGitmoji := ui.ListRun(listSettings, gitmojis.Gitmojis) log.Debugf("selected %s", selectedGitmoji) }, }
View Source
var RootCmd = &cobra.Command{ Use: pkg.ProgramName, 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") config, err := pkg.GetCurrentConfig() if err != nil { log.Fatalf("get current config issue, %s", err) } gitmojis := pkg.GetGitmojis(config) pkg.CacheGitmojis(gitmojis) }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.