Skip to content

Commit 5c06988

Browse files
committed
docs: improve documentation and command descriptions for clarity
- Update flag descriptions for better clarity and consistency - Change commit message descriptions to be more descriptive - Improve comments for better readability and understanding - Modify prompt command to include detailed usage and flag information - Refine hook command descriptions for better clarity - Update version command to include commit information Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent b4b6fcb commit 5c06988

File tree

6 files changed

+81
-64
lines changed

6 files changed

+81
-64
lines changed

cmd/commit.go

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

4545
func init() {
46-
commitCmd.PersistentFlags().StringP("file", "f", "", "commit message file")
47-
commitCmd.PersistentFlags().BoolVar(&preview, "preview", false, "preview commit message")
46+
commitCmd.PersistentFlags().StringP("file", "f", "", "output file for commit message")
47+
commitCmd.PersistentFlags().BoolVar(&preview, "preview", false, "preview commit message before committing")
4848
commitCmd.PersistentFlags().IntVar(&diffUnified, "diff_unified", 3,
49-
"generate diffs with <n> lines of context, default is 3")
50-
commitCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-4o", "select openai model")
51-
commitCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "summarizing language uses English by default")
49+
"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)")
5252
commitCmd.PersistentFlags().StringSliceVar(&excludeList, "exclude_list", []string{},
53-
"exclude file from git diff command")
54-
commitCmd.PersistentFlags().StringVar(&httpsProxy, "proxy", "", "http proxy")
55-
commitCmd.PersistentFlags().StringVar(&socksProxy, "socks", "", "socks proxy")
56-
commitCmd.PersistentFlags().StringVar(&templateFile, "template_file", "", "git commit message file")
57-
commitCmd.PersistentFlags().StringVar(&templateString, "template_string", "", "git commit message string")
58-
commitCmd.PersistentFlags().StringSliceVar(&templateVars, "template_vars", []string{}, "template variables")
59-
commitCmd.PersistentFlags().StringVar(&templateVarsFile, "template_vars_file", "", "template variables file")
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")
6060
commitCmd.PersistentFlags().BoolVar(&commitAmend, "amend", false,
61-
"replace the tip of the current branch by creating a new commit.")
62-
commitCmd.PersistentFlags().DurationVarP(&timeout, "timeout", "t", defaultTimeout, "request timeout")
61+
"amend the previous commit instead of creating a new one")
62+
commitCmd.PersistentFlags().DurationVarP(&timeout, "timeout", "t", defaultTimeout, "API request timeout duration")
6363
commitCmd.PersistentFlags().BoolVar(&promptOnly, "prompt_only", false,
64-
"show prompt only, don't send request to openai")
64+
"display the prompt without sending to OpenAI")
6565
commitCmd.PersistentFlags().BoolVar(&noConfirm, "no_confirm", false,
66-
"skip confirmation prompt")
66+
"skip all confirmation prompts")
6767
_ = viper.BindPFlag("output.file", commitCmd.PersistentFlags().Lookup("file"))
6868
}
6969

7070
// commitCmd represents the commit command.
7171
var commitCmd = &cobra.Command{
7272
Use: "commit",
73-
Short: "Auto generate commit message",
73+
Short: "Automatically generate commit message",
7474
RunE: func(cmd *cobra.Command, args []string) error {
7575
if err := check(); err != nil {
7676
return err
@@ -92,25 +92,25 @@ var commitCmd = &cobra.Command{
9292
viper.Set("openai.timeout", timeout)
9393
}
9494

95-
// check provider
95+
// Check provider
9696
provider := core.Platform(viper.GetString("openai.provider"))
9797
client, err := GetClient(cmd.Context(), provider)
9898
if err != nil && !promptOnly {
9999
return err
100100
}
101101

102102
currentModel := viper.GetString("openai.model")
103-
color.Green("Summarize the commit message use " + currentModel + " model")
103+
color.Green("Summarizing commit message using " + currentModel + " model")
104104

105105
data := util.Data{}
106-
// add template vars
106+
// Add template variables
107107
if vars := util.ConvertToMap(templateVars); len(vars) > 0 {
108108
for k, v := range vars {
109109
data[k] = v
110110
}
111111
}
112112

113-
// add template vars from file
113+
// Add template variables from file
114114
if templateVarsFile != "" {
115115
allENV, err := godotenv.Read(templateVarsFile)
116116
if err != nil {
@@ -121,7 +121,7 @@ var commitCmd = &cobra.Command{
121121
}
122122
}
123123

124-
// Get code review message from diff datas
124+
// Get code review message from diff data
125125
if _, ok := data[prompt.SummarizeMessageKey]; !ok {
126126
out, err := util.GetTemplateByString(
127127
prompt.SummarizeFileDiffTemplate,
@@ -133,16 +133,16 @@ var commitCmd = &cobra.Command{
133133
return err
134134
}
135135

136-
// determine if the user wants to use the prompt only
136+
// Determine if the user wants to use the prompt only
137137
if promptOnly {
138138
color.Yellow("====================Prompt========================")
139139
color.Yellow("\n" + strings.TrimSpace(out) + "\n\n")
140140
color.Yellow("==================================================")
141141
return nil
142142
}
143143

144-
// Get summarize comment from diff datas
145-
color.Cyan("We are trying to summarize a git diff")
144+
// Get summarized comment from diff data
145+
color.Cyan("Summarizing git diff...")
146146
resp, err := client.Completion(cmd.Context(), out)
147147
if err != nil {
148148
return err
@@ -151,7 +151,7 @@ var commitCmd = &cobra.Command{
151151
color.Magenta(resp.Usage.String())
152152
}
153153

154-
// Get summarize title from diff datas
154+
// Get summarized title from diff data
155155
if _, ok := data[prompt.SummarizeTitleKey]; !ok {
156156
out, err := util.GetTemplateByString(
157157
prompt.SummarizeTitleTemplate,
@@ -163,16 +163,16 @@ var commitCmd = &cobra.Command{
163163
return err
164164
}
165165

166-
// Get summarize title from diff datas
167-
color.Cyan("We are trying to summarize a title for pull request")
166+
// Generate title for pull request
167+
color.Cyan("Generating title for pull request...")
168168
resp, err := client.Completion(cmd.Context(), out)
169169
if err != nil {
170170
return err
171171
}
172172
summarizeTitle := resp.Content
173173
color.Magenta(resp.Usage.String())
174174

175-
// lowercase the first character of first word of the commit message and remove last period
175+
// Lowercase the first character of first word of the commit message and remove the trailing period
176176
summarizeTitle = strings.TrimRight(strings.ToLower(string(summarizeTitle[0]))+summarizeTitle[1:], ".")
177177
data[prompt.SummarizeTitleKey] = strings.TrimSpace(summarizeTitle)
178178
}
@@ -187,7 +187,7 @@ var commitCmd = &cobra.Command{
187187
if err != nil {
188188
return err
189189
}
190-
message := "We are trying to get conventional commit prefix"
190+
message := "Generating conventional commit prefix"
191191
summaryPrix := ""
192192
color.Cyan(message + " (Tools)")
193193
resp, err := client.GetSummaryPrefix(cmd.Context(), out)
@@ -244,8 +244,8 @@ var commitCmd = &cobra.Command{
244244
return err
245245
}
246246

247-
// translate a git commit message
248-
color.Cyan("We are trying to translate a git commit message to " + prompt.GetLanguage(viper.GetString("output.lang")) + " language")
247+
// Translate git commit message
248+
color.Cyan("Translating git commit message to " + prompt.GetLanguage(viper.GetString("output.lang")))
249249
resp, err := client.Completion(cmd.Context(), out)
250250
if err != nil {
251251
return err
@@ -254,7 +254,7 @@ var commitCmd = &cobra.Command{
254254
commitMessage = resp.Content
255255
}
256256

257-
// unescape html entities in commit message
257+
// Unescape HTML entities in commit message
258258
commitMessage = html.UnescapeString(commitMessage)
259259
commitMessage = strings.TrimSpace(commitMessage)
260260

@@ -271,8 +271,8 @@ var commitCmd = &cobra.Command{
271271
}
272272
outputFile = path.Join(strings.TrimSpace(out), "COMMIT_EDITMSG")
273273
}
274-
color.Cyan("Write the commit message to " + outputFile + " file")
275-
// write commit message to git staging file
274+
color.Cyan("Writing commit message to " + outputFile)
275+
// Write commit message to git staging file
276276
err = os.WriteFile(outputFile, []byte(commitMessage), 0o600)
277277
if err != nil {
278278
return err
@@ -283,7 +283,7 @@ var commitCmd = &cobra.Command{
283283
if noConfirm {
284284
return nil
285285
}
286-
if ready, err := confirmation.New("Commit preview summary?", confirmation.Yes).RunPrompt(); err != nil || !ready {
286+
if ready, err := confirmation.New("Commit this preview summary?", confirmation.Yes).RunPrompt(); err != nil || !ready {
287287
if err != nil {
288288
return err
289289
}
@@ -293,7 +293,7 @@ var commitCmd = &cobra.Command{
293293

294294
// Handle commit message change prompt when confirmation is enabled
295295
if !noConfirm {
296-
if change, err := confirmation.New("Do you want to change the commit message?", confirmation.No).RunPrompt(); err != nil {
296+
if change, err := confirmation.New("Do you want to modify the commit message?", confirmation.No).RunPrompt(); err != nil {
297297
return err
298298
} else if change {
299299
m := initialPrompt(commitMessage)
@@ -306,8 +306,8 @@ var commitCmd = &cobra.Command{
306306
}
307307
}
308308

309-
// git commit automatically
310-
color.Cyan("Git record changes to the repository")
309+
// Commit changes to repository
310+
color.Cyan("Recording changes to the repository")
311311
output, err := g.Commit(commitMessage)
312312
if err != nil {
313313
return err

cmd/hook.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ func init() {
1212
hookCmd.AddCommand(hookUninstallCmd)
1313
}
1414

15-
// hookCmd represents the command for installing/uninstalling the prepare-commit-msg hook.
15+
// hookCmd represents the command for managing the prepare-commit-msg git hook.
1616
var hookCmd = &cobra.Command{
1717
Use: "hook",
18-
Short: "install/uninstall git prepare-commit-msg hook",
18+
Short: "Manage git prepare-commit-msg hook",
1919
}
2020

2121
// hookInstallCmd installs the prepare-commit-msg hook.
2222
var hookInstallCmd = &cobra.Command{
2323
Use: "install",
24-
Short: "install git prepare-commit-msg hook",
24+
Short: "Install git prepare-commit-msg hook",
2525
RunE: func(cmd *cobra.Command, args []string) error {
2626
g := git.New()
2727

2828
if err := g.InstallHook(); err != nil {
2929
return err
3030
}
31-
color.Green("Install git hook: prepare-commit-msg successfully")
32-
color.Green("You can see the hook file: .git/hooks/prepare-commit-msg")
31+
color.Green("Git hook 'prepare-commit-msg' installed successfully")
32+
color.Green("Hook file location: .git/hooks/prepare-commit-msg")
3333

3434
return nil
3535
},
@@ -38,14 +38,14 @@ var hookInstallCmd = &cobra.Command{
3838
// hookUninstallCmd uninstalls the prepare-commit-msg hook.
3939
var hookUninstallCmd = &cobra.Command{
4040
Use: "uninstall",
41-
Short: "uninstall git prepare-commit-msg hook",
41+
Short: "Uninstall git prepare-commit-msg hook",
4242
RunE: func(cmd *cobra.Command, args []string) error {
4343
g := git.New()
4444

4545
if err := g.UninstallHook(); err != nil {
4646
return err
4747
}
48-
color.Green("Remove git hook: prepare-commit-msg successfully")
48+
color.Green("Git hook 'prepare-commit-msg' removed successfully")
4949
return nil
5050
},
5151
}

cmd/prompt.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var loadPromptData bool
1515

1616
func init() {
1717
promptCmd.PersistentFlags().BoolVar(&loadPromptData, "load", false,
18-
"load default prompt data")
18+
"Load default prompt templates into your configuration")
1919
}
2020

2121
var defaultPromptDataKeys = []string{
@@ -25,15 +25,32 @@ var defaultPromptDataKeys = []string{
2525
prompt.ConventionalCommitTemplate,
2626
}
2727

28-
// promptCmd represents the command to load default prompt data.
29-
// It uses the "prompt" keyword and provides a short description: "load default prompt data".
30-
// The command executes the RunE function which checks if the loadPromptData flag is set.
31-
// If set, it prompts the user for confirmation to load the default prompt data, which will overwrite existing data.
32-
// Upon confirmation, it retrieves the prompt folder path from the configuration and saves the default prompt data keys to the specified folder.
33-
// If any error occurs during the process, it returns the error.
28+
// promptCmd is a Cobra command to load default prompt data into a specified folder.
29+
// It provides functionality to populate the prompt folder with predefined templates.
30+
//
31+
// Usage:
32+
//
33+
// codegpt prompt [flags]
34+
//
35+
// Flags:
36+
//
37+
// -l, --load load default prompt data into the specified folder (required to execute)
38+
//
39+
// This command will:
40+
// 1. Check if the load flag is enabled
41+
// 2. Get the prompt folder path from configuration
42+
// 3. Ask for user confirmation before proceeding with data loading
43+
// 4. Save all default prompt templates to the specified folder
44+
//
45+
// The command requires explicit confirmation from the user as it may overwrite existing prompt data.
3446
var promptCmd = &cobra.Command{
3547
Use: "prompt",
36-
Short: "load default prompt data",
48+
Short: "Load default prompt templates",
49+
Long: `Load default prompt templates into your configuration directory.
50+
51+
This command allows you to initialize or update your prompt templates with the default set provided by CodeGPT.
52+
When executed with the --load flag, it will copy all standard templates to your configured prompt folder.`,
53+
Example: " codegpt prompt --load",
3754
RunE: func(cmd *cobra.Command, args []string) error {
3855
if !loadPromptData {
3956
return nil

cmd/review.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ var maxTokens int
1919

2020
func init() {
2121
reviewCmd.PersistentFlags().IntVar(&diffUnified, "diff_unified", 3,
22-
"generate diffs with <n> lines of context, default is 3")
22+
"Generate diffs with <n> lines of context (default: 3)")
2323
reviewCmd.PersistentFlags().IntVar(&maxTokens, "max_tokens", 300,
24-
"the maximum number of tokens to generate in the chat completion.")
25-
reviewCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-4o", "select openai model")
26-
reviewCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "summarizing language uses English by default")
27-
reviewCmd.PersistentFlags().StringSliceVar(&excludeList, "exclude_list", []string{}, "exclude file from git diff command")
24+
"Maximum number of tokens to generate in the chat completion")
25+
reviewCmd.PersistentFlags().StringVar(&commitModel, "model", "gpt-4o", "OpenAI model to use")
26+
reviewCmd.PersistentFlags().StringVar(&commitLang, "lang", "en", "Language for summarization (default: English)")
27+
reviewCmd.PersistentFlags().StringSliceVar(&excludeList, "exclude_list", []string{}, "Files to exclude from git diff")
2828
reviewCmd.PersistentFlags().BoolVar(&commitAmend, "amend", false,
29-
"replace the tip of the current branch by creating a new commit.")
29+
"Replace the tip of the current branch by creating a new commit")
3030
reviewCmd.PersistentFlags().BoolVar(&promptOnly, "prompt_only", false,
31-
"show prompt only, don't send request to openai")
31+
"Show prompt only without sending request to OpenAI")
3232
}
3333

3434
var reviewCmd = &cobra.Command{

cmd/textarea.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
8484

8585
func (m model) View() string {
8686
return fmt.Sprintf(
87-
"Please confirm the following commit message:\n\n%s\n\n%s",
87+
"Please review and confirm your commit message:\n\n%s\n\n%s",
8888
m.textarea.View(),
89-
"(Press Ctrl+C to continue.)",
89+
"(Press Ctrl+C to continue)",
9090
) + "\n\n"
9191
}

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var (
1313

1414
var versionCmd = &cobra.Command{
1515
Use: "version",
16-
Short: "Print the version number",
16+
Short: "Print the application version and commit information",
1717
Run: func(cmd *cobra.Command, args []string) {
1818
fmt.Println("version:", Version, "commit:", Commit)
1919
},

0 commit comments

Comments
 (0)