-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI: app, command, and subcommand templates
* swap options and args in all three * fix all readmes Signed-off-by: Alex Aizman <[email protected]>
- Loading branch information
1 parent
b61478e
commit 45c69e4
Showing
29 changed files
with
154 additions
and
102 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
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
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
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,81 @@ | ||
// Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters. | ||
/* | ||
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package cli | ||
|
||
// custom cli.AppHelpTemplate | ||
// "You can render custom help text by setting this variable." (from github.com/urfave/cli) | ||
const ( | ||
appHelpTemplate = `NAME: | ||
{{.Name}}{{if .Usage}} - {{.Usage}}{{end}} | ||
USAGE: | ||
{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .VisibleFlags}}[global options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}} {{if .Commands}} command [command options]{{end}} {{end}} {{if .Version}}{{if not .HideVersion}} | ||
VERSION: | ||
{{.Version}}{{end}}{{end}}{{if .Description}} | ||
TAB completions (Bash and Zsh): | ||
{{.Description}}{{end}}{{if len .Authors}} | ||
AUTHOR{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}: | ||
{{range $index, $author := .Authors}}{{if $index}} | ||
{{end}}{{$author}}{{end}}{{end}}{{if .VisibleCommands}} | ||
COMMANDS:{{range .VisibleCategories}}{{if .Name}} | ||
{{.Name}}:{{range .VisibleCommands}} | ||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}} | ||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} | ||
GLOBAL OPTIONS: | ||
{{range $index, $option := .VisibleFlags}}{{if $index}} | ||
{{end}}{{$option}}{{end}}{{end}}{{if .Copyright}} | ||
COPYRIGHT: | ||
{{.Copyright}}{{end}} | ||
` | ||
) | ||
|
||
// custom cli.CommandHelpTemplate | ||
// "... cli.go uses text/template to render templates. You can render custom help text by setting this variable." | ||
const ( | ||
commandHelpTemplate = `NAME: | ||
{{.HelpName}} - {{.Usage}} | ||
USAGE: | ||
{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{if .VisibleFlags}} [command options]{{end}} {{end}}{{if .Category}} | ||
CATEGORY: | ||
{{.Category}}{{end}}{{if .Description}} | ||
DESCRIPTION: | ||
{{.Description}}{{end}}{{if .VisibleFlags}} | ||
OPTIONS: | ||
{{range .VisibleFlags}}{{.}} | ||
{{end}}{{end}} | ||
` | ||
) | ||
|
||
// custom cli.SubcommandHelpTemplate | ||
// "... cli.go uses text/template to render templates. You can render custom help text by setting this variable." | ||
const ( | ||
subcommandHelpTemplate = `NAME: | ||
{{.HelpName}} - {{if .Description}}{{.Description}}{{else}}{{.Usage}}{{end}} | ||
USAGE: | ||
{{if .UsageText}}{{.UsageText}}{{else}}{{.HelpName}} command {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}} {{if .VisibleFlags}} [command options]{{end}}{{end}} | ||
COMMANDS:{{range .VisibleCategories}}{{if .Name}} | ||
{{.Name}}:{{range .VisibleCommands}} | ||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{else}}{{range .VisibleCommands}} | ||
{{join .Names ", "}}{{"\t"}}{{.Usage}}{{end}}{{end}}{{end}}{{if .VisibleFlags}} | ||
OPTIONS: | ||
{{range .VisibleFlags}}{{.}} | ||
{{end}}{{end}} | ||
` | ||
) |
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
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
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
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
Oops, something went wrong.