Skip to content

Commit e110d8d

Browse files
committed
docs: improve command usage documentation
This PR makes command usage documentation consistent by enforcing [docopt](http://docopt.org/) rules and also defining and documenting other additional conventions.
1 parent 4712950 commit e110d8d

File tree

92 files changed

+107
-92
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+107
-92
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions

internal/cmd/all/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var ListCmd = base.Cmd{
5050
}
5151

5252
cmd := &cobra.Command{
53-
Use: "list FLAGS",
53+
Use: "list [options]",
5454
Short: "List all resources in the project",
5555
Long: `List all resources in the project. This does not include static/public resources like locations, public ISOs, etc.
5656

internal/cmd/base/delete.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ type DeleteCmd struct {
2626

2727
// CobraCommand creates a command that can be registered with cobra.
2828
func (dc *DeleteCmd) CobraCommand(s state.State) *cobra.Command {
29+
opts := ""
30+
if dc.AdditionalFlags != nil {
31+
opts = "[options] "
32+
}
33+
2934
cmd := &cobra.Command{
30-
Use: fmt.Sprintf("delete [FLAGS] %s", strings.ToUpper(dc.ResourceNameSingular)),
35+
Use: fmt.Sprintf("delete %s<%s>", opts, strings.ToLower(dc.ResourceNameSingular)),
3136
Short: dc.ShortDescription,
3237
Args: cobra.ExactArgs(1),
3338
ValidArgsFunction: cmpl.SuggestArgs(cmpl.SuggestCandidatesF(dc.NameSuggestions(s.Client()))),

internal/cmd/base/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type DescribeCmd struct {
3333
// CobraCommand creates a command that can be registered with cobra.
3434
func (dc *DescribeCmd) CobraCommand(s state.State) *cobra.Command {
3535
cmd := &cobra.Command{
36-
Use: fmt.Sprintf("describe [FLAGS] %s", strings.ToUpper(dc.ResourceNameSingular)),
36+
Use: fmt.Sprintf("describe [options] <%s>", strings.ToLower(dc.ResourceNameSingular)),
3737
Short: dc.ShortDescription,
3838
Args: cobra.ExactArgs(1),
3939
ValidArgsFunction: cmpl.SuggestArgs(cmpl.SuggestCandidatesF(dc.NameSuggestions(s.Client()))),

internal/cmd/base/labels.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type LabelCmds struct {
2727
// AddCobraCommand creates a command that can be registered with cobra.
2828
func (lc *LabelCmds) AddCobraCommand(s state.State) *cobra.Command {
2929
cmd := &cobra.Command{
30-
Use: fmt.Sprintf("add-label [FLAGS] %s LABEL...", strings.ToUpper(lc.ResourceNameSingular)),
30+
Use: fmt.Sprintf("add-label [--overwrite] <%s> <label>...", strings.ToLower(lc.ResourceNameSingular)),
3131
Short: lc.ShortDescriptionAdd,
3232
Args: cobra.MinimumNArgs(2),
3333
ValidArgsFunction: cmpl.SuggestArgs(cmpl.SuggestCandidatesF(lc.NameSuggestions(s.Client()))),
@@ -89,7 +89,7 @@ func validateAddLabel(_ *cobra.Command, args []string) error {
8989
// RemoveCobraCommand creates a command that can be registered with cobra.
9090
func (lc *LabelCmds) RemoveCobraCommand(s state.State) *cobra.Command {
9191
cmd := &cobra.Command{
92-
Use: fmt.Sprintf("remove-label [FLAGS] %s LABEL...", strings.ToUpper(lc.ResourceNameSingular)),
92+
Use: fmt.Sprintf("remove-label <%s> (--all | <label>...)", strings.ToLower(lc.ResourceNameSingular)),
9393
Short: lc.ShortDescriptionRemove,
9494
Args: cobra.MinimumNArgs(1),
9595
ValidArgsFunction: cmpl.SuggestArgs(

internal/cmd/base/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (lc *ListCmd) CobraCommand(s state.State) *cobra.Command {
2929
outputColumns := lc.OutputTable(s.Client()).Columns()
3030

3131
cmd := &cobra.Command{
32-
Use: "list [FlAGS]",
32+
Use: "list [options]",
3333
Short: fmt.Sprintf("List %s", lc.ResourceNamePlural),
3434
Long: util.ListLongDescription(
3535
fmt.Sprintf("Displays a list of %s.", lc.ResourceNamePlural),

internal/cmd/base/set_rdns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type SetRdnsCmd struct {
2828
// CobraCommand creates a command that can be registered with cobra.
2929
func (rc *SetRdnsCmd) CobraCommand(s state.State) *cobra.Command {
3030
cmd := &cobra.Command{
31-
Use: fmt.Sprintf("set-rdns [FLAGS] %s", strings.ToUpper(rc.ResourceNameSingular)),
31+
Use: fmt.Sprintf("set-rdns [options] <%s> --hostname <hostname>", strings.ToLower(rc.ResourceNameSingular)),
3232
Short: rc.ShortDescription,
3333
Args: cobra.ExactArgs(1),
3434
ValidArgsFunction: cmpl.SuggestArgs(cmpl.SuggestCandidatesF(rc.NameSuggestions(s.Client()))),

internal/cmd/base/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type UpdateCmd struct {
2828
// CobraCommand creates a command that can be registered with cobra.
2929
func (uc *UpdateCmd) CobraCommand(s state.State) *cobra.Command {
3030
cmd := &cobra.Command{
31-
Use: fmt.Sprintf("update [FLAGS] %s", strings.ToUpper(uc.ResourceNameSingular)),
31+
Use: fmt.Sprintf("update [options] <%s>", strings.ToLower(uc.ResourceNameSingular)),
3232
Short: uc.ShortDescription,
3333
Args: cobra.ExactArgs(1),
3434
ValidArgsFunction: cmpl.SuggestArgs(cmpl.SuggestCandidatesF(uc.NameSuggestions(s.Client()))),

internal/cmd/certificate/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
var CreateCmd = base.CreateCmd{
1818
BaseCobraCommand: func(client hcapi2.Client) *cobra.Command {
1919
cmd := &cobra.Command{
20-
Use: "create [FLAGS]",
20+
Use: "create [options] --name <name> (--type managed | --type uploaded --cert-file <file> --key-file <file>)",
2121
Short: "Create or upload a Certificate",
2222
Args: cobra.ExactArgs(0),
2323
}

internal/cmd/completion/completion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333

3434
func NewCommand(_ state.State) *cobra.Command {
3535
cmd := &cobra.Command{
36-
Use: "completion [FLAGS] SHELL",
36+
Use: "completion <shell>",
3737
Short: "Output shell completion code for the specified shell",
3838
Long: `To load completions:
3939

0 commit comments

Comments
 (0)