Skip to content

Commit 25a804a

Browse files
committed
Add usage documentation
1 parent 439c22d commit 25a804a

File tree

16 files changed

+202
-11
lines changed

16 files changed

+202
-11
lines changed

Justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ clean:
99

1010
run *commands:
1111
go run main.go {{commands}}
12+
13+
cobra-docs:
14+
go run docs/gen_docs.go

cmd/chat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ If '-q' is not specified, the user will be prompted to enter a question.
5555
}
5656

5757
func init() {
58-
rootCmd.AddCommand(chatCmd)
58+
RootCmd.AddCommand(chatCmd)
5959

6060
chatCmd.Flags().StringVarP(&question, "question", "q", "", "Question to chat ChatGPT")
6161
}

cmd/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var docCmd = &cobra.Command{
7979
}
8080

8181
func init() {
82-
rootCmd.AddCommand(docCmd)
82+
RootCmd.AddCommand(docCmd)
8383

8484
// see cmd/vars.go for the definition of these flags
8585
docCmd.Flags().StringVarP(&filePath, "file", "f", "", "The file to document")

cmd/docs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ search for files in the directory and document them.
135135
}
136136

137137
func init() {
138-
rootCmd.AddCommand(docsCmd)
138+
RootCmd.AddCommand(docsCmd)
139139

140140
// see cmd/vars for the definition of these flags
141141
docsCmd.Flags().StringVarP(&chatPrompt, "prompt", "p", "", "Prompt to use for the ChatGPT API")

cmd/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ This API key will be used to authenticate with the OpenAI ChatGPT API.`,
4242
}
4343

4444
func init() {
45-
rootCmd.AddCommand(loginCmd)
45+
RootCmd.AddCommand(loginCmd)
4646

4747
loginCmd.Flags().StringVarP(&apiKey, "apikey", "k", "", "API key to add to configuration")
4848
}

cmd/prompt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var promptCmd = &cobra.Command{
7878
}
7979

8080
func init() {
81-
rootCmd.AddCommand(promptCmd)
81+
RootCmd.AddCommand(promptCmd)
8282

8383
// see cmd/vars.go for the definition of these flags
8484
promptCmd.Flags().StringVarP(&preambleFile, "preamble", "p", "", "path to preamble text file")

cmd/root.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"github.com/spf13/cobra"
1010
)
1111

12-
// rootCmd represents the base command when called without any subcommands
13-
var rootCmd = &cobra.Command{
12+
// RootCmd represents the base command when called without any subcommands
13+
var RootCmd = &cobra.Command{
1414
Use: "otto",
1515
Short: "Document your code with ease",
1616
Long: `Code documentation made easy using GPT.`,
@@ -20,9 +20,9 @@ var rootCmd = &cobra.Command{
2020
}
2121

2222
// Execute adds all child commands to the root command and sets flags appropriately.
23-
// This is called by main.main(). It only needs to happen once to the rootCmd.
23+
// This is called by main.main(). It only needs to happen once to the RootCmd.
2424
func Execute() {
25-
err := rootCmd.Execute()
25+
err := RootCmd.Execute()
2626
if err != nil {
2727
os.Exit(1)
2828
}
@@ -33,9 +33,9 @@ func init() {
3333
// Cobra supports persistent flags, which, if defined here,
3434
// will be global for your application.
3535

36-
// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.ottodocs.yaml)")
36+
// RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.ottodocs.yaml)")
3737

3838
// Cobra also supports local flags, which will only run
3939
// when this action is called directly.
40-
// rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
40+
// RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
4141
}

docs/gen_docs.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"github.com/chand1012/ottodocs/cmd"
5+
"github.com/spf13/cobra/doc"
6+
)
7+
8+
func main() {
9+
err := doc.GenMarkdownTree(cmd.RootCmd, "./docs")
10+
if err != nil {
11+
panic(err)
12+
}
13+
}

docs/otto.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## otto
2+
3+
Document your code with ease
4+
5+
### Synopsis
6+
7+
Code documentation made easy using GPT.
8+
9+
### Options
10+
11+
```
12+
-h, --help help for otto
13+
```
14+
15+
### SEE ALSO
16+
17+
* [otto chat](otto_chat.md) - Ask ChatGPT a question from the command line.
18+
* [otto doc](otto_doc.md) - Document a file
19+
* [otto docs](otto_docs.md) - Document a repository of files
20+
* [otto login](otto_login.md) - Add an API key to your configuration
21+
* [otto prompt](otto_prompt.md) - Generates a ChatGPT prompt from a given Git repo
22+
23+
###### Auto generated by spf13/cobra on 18-Mar-2023

docs/otto_chat.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## otto chat
2+
3+
Ask ChatGPT a question from the command line.
4+
5+
### Synopsis
6+
7+
Ask ChatGPT a question from the command line.
8+
9+
If '-q' is not specified, the user will be prompted to enter a question.
10+
11+
12+
```
13+
otto chat [flags]
14+
```
15+
16+
### Options
17+
18+
```
19+
-h, --help help for chat
20+
-q, --question string Question to chat ChatGPT
21+
```
22+
23+
### SEE ALSO
24+
25+
* [otto](otto.md) - Document your code with ease
26+
27+
###### Auto generated by spf13/cobra on 18-Mar-2023

0 commit comments

Comments
 (0)