Skip to content

Commit

Permalink
improve usage messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hurngchunlee committed Nov 4, 2019
1 parent 64e6fd7 commit 765fa5d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
27 changes: 15 additions & 12 deletions internal/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ var jobCmd = &cobra.Command{
}

var jobTraceCmd = &cobra.Command{
Use: "trace [JobID]",
Short: "Print job's trace log available on the Torque server.",
Long: ``,
Use: "trace [id]",
Short: "Print trace log of a job.",
Long: `Print trace log of a job retrieved from the Torque server.
Only the trace log recorded in the last 3 days will be shown.
`,
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
c := trqhelper.TorqueHelperSrvClient{
Expand All @@ -233,7 +236,7 @@ var jobTraceCmd = &cobra.Command{
}

var jobMeminfoCmd = &cobra.Command{
Use: "meminfo [JobID]",
Use: "meminfo [id]",
Short: "Print memory usage of a running job.",
Long: ``,
Args: cobra.MinimumNArgs(1),
Expand Down Expand Up @@ -273,8 +276,8 @@ var nodeCmd = &cobra.Command{
}

var nodeMeminfoCmd = &cobra.Command{
Use: "memfree {access|compute}",
Short: "Print total and free memory on the cluster nodes.",
Use: "memfree [access|compute]",
Short: "Print total and free memory of cluster nodes.",
Long: ``,
ValidArgs: []string{nodeTypeNames[access], nodeTypeNames[compute]},
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -295,8 +298,8 @@ var nodeMeminfoCmd = &cobra.Command{
}

var nodeDiskinfoCmd = &cobra.Command{
Use: "diskfree {access|compute}",
Short: "Print total and free disk space of the cluster nodes.",
Use: "diskfree [access|compute]",
Short: "Print total and free disk space of cluster nodes.",
Long: ``,
ValidArgs: []string{nodeTypeNames[access], nodeTypeNames[compute]},
Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -317,7 +320,7 @@ var nodeDiskinfoCmd = &cobra.Command{
}

var nodeInfoCmd = &cobra.Command{
Use: "info {access|compute}",
Use: "info [access|compute]",
Short: "Print system load and resource availability of cluster nodes.",
Long: ``,
ValidArgs: []string{nodeTypeNames[access], nodeTypeNames[compute]},
Expand All @@ -339,9 +342,9 @@ var nodeInfoCmd = &cobra.Command{
}

var nodeVncCmd = &cobra.Command{
Use: "vnc [{host1} {host2} ...]",
Short: "Print list of VNC servers on the cluster or a specific node.",
Long: `Print list of VNC servers on the cluster or a specific node.
Use: "vnc [host1 host2 ...]",
Short: "Print VNC servers in the cluster or on specific nodes.",
Long: `Print VNC servers in the cluster or on specific nodes.
If the {hostname} is specified, only the VNCs on the node will be shown.
Expand Down
13 changes: 8 additions & 5 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ var availCmd = &cobra.Command{
table.SetHeader([]string{"Command", "Description"})
table.SetRowSeparator("-")
addCommandUseToTable(rootCmd, "", table)
table.SetColWidth(40)
table.Render()
},
}
Expand All @@ -109,10 +108,14 @@ var availCmd = &cobra.Command{
// `tablewritter.Table`.
func addCommandUseToTable(cmd *cobra.Command, parentUse string, table *tablewriter.Table) {
for _, c := range cmd.Commands() {
table.Append([]string{
fmt.Sprintf("%s %s %s", parentUse, cmd.Use, c.Use),
c.Short,
})

// only prints the command itself if there is no further sub-commands
if len(c.Commands()) == 0 {
table.Append([]string{
fmt.Sprintf("%s %s %s", parentUse, cmd.Use, c.Use),
c.Short,
})
}
addCommandUseToTable(c, fmt.Sprintf("%s %s", parentUse, cmd.Use), table)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var webhookCmd = &cobra.Command{
}

var createCmd = &cobra.Command{
Use: "create [ScriptPath]",
Use: "create [path]",
Short: "Create a new webhook.",
Long: ``,
Args: func(cmd *cobra.Command, args []string) error {
Expand Down

0 comments on commit 765fa5d

Please sign in to comment.