Skip to content

Commit 4d02d6e

Browse files
committed
docs: improve documentation and clarity across multiple files
- Update flag descriptions for better clarity in `commit.go` - Expand the `Long` description in `completion.go` to include detailed instructions for loading shell completions - Improve comments and error messages in `config.go` and `hepler.go` for better readability and clarity Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 5c06988 commit 4d02d6e

File tree

4 files changed

+42
-23
lines changed

4 files changed

+42
-23
lines changed

cmd/commit.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ var (
4343
)
4444

4545
func init() {
46-
commitCmd.PersistentFlags().StringP("file", "f", "", "output file for commit message")
46+
commitCmd.PersistentFlags().StringP("file", "f", "", "specify output file for commit message")
4747
commitCmd.PersistentFlags().BoolVar(&preview, "preview", false, "preview commit message before committing")
4848
commitCmd.PersistentFlags().IntVar(&diffUnified, "diff_unified", 3,
4949
"generate diffs with <n> lines of context (default: 3)")
50-
commitCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-4o", "OpenAI model to use for generation")
51-
commitCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "output language for the commit message (default: English)")
50+
commitCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-4o", "specify which OpenAI model to use for generation")
51+
commitCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "set output language for the commit message (default: English)")
5252
commitCmd.PersistentFlags().StringSliceVar(&excludeList, "exclude_list", []string{},
53-
"files to exclude from git diff")
54-
commitCmd.PersistentFlags().StringVar(&httpsProxy, "proxy", "", "HTTP proxy URL")
55-
commitCmd.PersistentFlags().StringVar(&socksProxy, "socks", "", "SOCKS proxy URL")
56-
commitCmd.PersistentFlags().StringVar(&templateFile, "template_file", "", "template file for commit message format")
57-
commitCmd.PersistentFlags().StringVar(&templateString, "template_string", "", "inline template string for commit message format")
58-
commitCmd.PersistentFlags().StringSliceVar(&templateVars, "template_vars", []string{}, "custom variables for templates")
59-
commitCmd.PersistentFlags().StringVar(&templateVarsFile, "template_vars_file", "", "file containing template variables")
53+
"specify files to exclude from git diff")
54+
commitCmd.PersistentFlags().StringVar(&httpsProxy, "proxy", "", "set HTTP proxy URL")
55+
commitCmd.PersistentFlags().StringVar(&socksProxy, "socks", "", "set SOCKS proxy URL")
56+
commitCmd.PersistentFlags().StringVar(&templateFile, "template_file", "", "provide template file for commit message format")
57+
commitCmd.PersistentFlags().StringVar(&templateString, "template_string", "", "provide inline template string for commit message format")
58+
commitCmd.PersistentFlags().StringSliceVar(&templateVars, "template_vars", []string{}, "define custom variables for templates")
59+
commitCmd.PersistentFlags().StringVar(&templateVarsFile, "template_vars_file", "", "specify file containing template variables")
6060
commitCmd.PersistentFlags().BoolVar(&commitAmend, "amend", false,
6161
"amend the previous commit instead of creating a new one")
62-
commitCmd.PersistentFlags().DurationVarP(&timeout, "timeout", "t", defaultTimeout, "API request timeout duration")
62+
commitCmd.PersistentFlags().DurationVarP(&timeout, "timeout", "t", defaultTimeout, "set API request timeout duration")
6363
commitCmd.PersistentFlags().BoolVar(&promptOnly, "prompt_only", false,
6464
"display the prompt without sending to OpenAI")
6565
commitCmd.PersistentFlags().BoolVar(&noConfirm, "no_confirm", false,

cmd/completion.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,29 @@ import (
77
)
88

99
var CompletionCmd = &cobra.Command{
10-
Use: "completion [bash|zsh|fish|powershell]",
11-
Short: "Generate completion script",
12-
Long: "To load completions",
10+
Use: "completion [bash|zsh|fish|powershell]",
11+
Short: "Generate completion script",
12+
Long: `Generate shell completion scripts for CodeGPT CLI.
13+
14+
To load completions:
15+
16+
Bash:
17+
$ source <(codegpt completion bash)
18+
# Or save it to a file and source it:
19+
$ codegpt completion bash > ~/.codegpt-completion.bash
20+
$ echo 'source ~/.codegpt-completion.bash' >> ~/.bashrc
21+
22+
Zsh:
23+
$ source <(codegpt completion zsh)
24+
# Or save it to a file in your $fpath:
25+
$ codegpt completion zsh > "${fpath[1]}/_codegpt"
26+
27+
Fish:
28+
$ codegpt completion fish > ~/.config/fish/completions/codegpt.fish
29+
30+
PowerShell:
31+
PS> codegpt completion powershell > codegpt.ps1
32+
PS> . ./codegpt.ps1`,
1333
DisableFlagsInUseLine: true,
1434
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
1535
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),

cmd/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
)
66

77
// configCmd represents the command for custom configuration,
8-
// including openai.api_key and openai.model and etc...
8+
// including settings like openai.api_key, openai.model, and others.
99
var configCmd = &cobra.Command{
1010
Use: "config",
11-
Short: "custom config (openai.api_key, openai.model ...)",
11+
Short: "Customize configuration settings (API key, model selection, etc.)",
1212
}

cmd/hepler.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ import (
88
"github.com/appleboy/CodeGPT/provider/openai"
99
"github.com/appleboy/CodeGPT/util"
1010
"github.com/appleboy/com/file"
11-
1211
"github.com/spf13/viper"
1312
)
1413

1514
func check() error {
1615
// Check if the Git command is available on the system's PATH
1716
if !util.IsCommandAvailable("git") {
18-
return errors.New("git command not found on your system's PATH. Please install Git and try again")
17+
return errors.New("git command not found in your system's PATH. Please install Git and try again")
1918
}
2019

21-
// Update Viper configuration values based on the CLI flags
20+
// Apply configuration values from CLI flags to Viper
2221
if diffUnified != 3 {
2322
viper.Set("git.diff_unified", diffUnified)
2423
}
@@ -55,17 +54,17 @@ func check() error {
5554
viper.Set("git.template_string", templateString)
5655
}
5756

58-
// Check if the template file specified in the configuration exists
57+
// Verify template file existence
5958
templateFile := viper.GetString("git.template_file")
6059
if templateFile != "" && !file.IsFile(templateFile) {
61-
return fmt.Errorf("template file not found: %s", templateFile)
60+
return fmt.Errorf("template file not found at: %s", templateFile)
6261
}
6362

6463
if templateVarsFile != "" && !file.IsFile(templateVarsFile) {
65-
return fmt.Errorf("template variables file not found: %s", templateVarsFile)
64+
return fmt.Errorf("template variables file not found at: %s", templateVarsFile)
6665
}
6766

68-
// load custom prompt
67+
// Load custom prompts from configured directory
6968
promptFolder := viper.GetString("prompt.folder")
7069
if promptFolder != "" {
7170
if err := util.LoadTemplatesFromDir(promptFolder); err != nil {

0 commit comments

Comments
 (0)