-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: now the documentation for the pizza-cli can be generated via pi…
…zza docs
- Loading branch information
1 parent
cd4b8da
commit f63ca9f
Showing
9 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package docs | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/cobra/doc" | ||
) | ||
|
||
type Options struct { | ||
// the path location to generate the documentation | ||
path string | ||
} | ||
|
||
const DefaultPath = "./docs" | ||
|
||
func NewDocsCommand() *cobra.Command { | ||
opts := &Options{} | ||
|
||
return &cobra.Command{ | ||
Use: "docs", | ||
Short: "Generates the documentation for the CLI", | ||
Args: cobra.MaximumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
// Use default path if no argument is provided | ||
if len(args) == 0 { | ||
opts.path = DefaultPath | ||
fmt.Printf("No path was provided. Using default path: %s\n", DefaultPath) | ||
} else { | ||
absPath, err := filepath.Abs(args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
opts.path = absPath | ||
} | ||
|
||
// Create the directory if it doesn't exist | ||
_, err := os.Stat(opts.path) | ||
if os.IsNotExist(err) { | ||
fmt.Printf("The directory %s does not exist. Creating it...\n", opts.path) | ||
|
||
err := os.MkdirAll(opts.path, os.ModePerm) | ||
if err != nil { | ||
return fmt.Errorf("error creating documentation output directory %s: %s", opts.path, err) | ||
} | ||
} | ||
|
||
// Generate markdown documentation | ||
fmt.Printf("Generating documentation in %s...\n", opts.path) | ||
err = doc.GenMarkdownTree(cmd, opts.path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("Finished generating documentation in %s\n", opts.path) | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## pizza docs | ||
|
||
Generates the documentation for the CLI | ||
|
||
``` | ||
pizza docs [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for docs | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
-c, --config string The saucectl config (default "~/.sauced.yaml") | ||
--disable-telemetry Disable sending telemetry data to OpenSauced | ||
-l, --log-level string The logging level. Options: error, warn, info, debug (default "info") | ||
--tty-disable Disable log stylization. Suitable for CI/CD and automation | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [pizza](pizza.md) - OpenSauced CLI | ||
|
||
###### Auto generated by spf13/cobra on 4-Sep-2024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## pizza docs | ||
|
||
Generates the documentation for the CLI | ||
|
||
``` | ||
pizza docs [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-h, --help help for docs | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
-c, --config string The saucectl config (default "~/.sauced.yaml") | ||
--disable-telemetry Disable sending telemetry data to OpenSauced | ||
-l, --log-level string The logging level. Options: error, warn, info, debug (default "info") | ||
--tty-disable Disable log stylization. Suitable for CI/CD and automation | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [pizza](pizza.md) - OpenSauced CLI | ||
|
||
###### Auto generated by spf13/cobra on 4-Sep-2024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters