Command-Line Programs
Usage Output
A usage message shows the accepted command shape when input is incomplete or unclear.
Usage Output
usage_output.go
package main
import "fmt"
func usage(command string) []string {
lines := []string{
"usage: tool " + command + " [options]",
" --help show help",
" --limit N choose a small limit",
}
return lines
}
func main() {
var command =
lines := usage(command)
for index, line := range lines {
fmt.Println(index, line)
}
fmt.Println("lineCount=", len(lines))
}
package main
import "fmt"
func usage(command string) []string {
lines := []string{
"usage: tool " + command + " [options]",
" --help show help",
" --limit N choose a small limit",
}
return lines
}
func main() {
var command =
lines := usage(command)
for index, line := range lines {
fmt.Println(index, line)
}
fmt.Println("lineCount=", len(lines))
}
package main
import "fmt"
func usage(command string) []string {
lines := []string{
"usage: tool " + command + " [options]",
" --help show help",
" --limit N choose a small limit",
}
return lines
}
func main() {
var command =
lines := usage(command)
for index, line := range lines {
fmt.Println(index, line)
}
fmt.Println("lineCount=", len(lines))
}
usage text
Usage text is a short guide that tells the user how to call a command.