31 lines
518 B
Go
31 lines
518 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
)
|
|
|
|
const usage = "Usage:\n notarius help\n"
|
|
|
|
// Run executes the command-line interface and returns a process exit code.
|
|
func Run(args []string, stdout, stderr io.Writer) int {
|
|
if len(args) == 0 {
|
|
writeUsage(stdout)
|
|
return 0
|
|
}
|
|
|
|
switch args[0] {
|
|
case "help", "--help", "-h":
|
|
writeUsage(stdout)
|
|
return 0
|
|
default:
|
|
fmt.Fprintf(stderr, "notarius: unknown command %q\n", args[0])
|
|
writeUsage(stderr)
|
|
return 2
|
|
}
|
|
}
|
|
|
|
func writeUsage(w io.Writer) {
|
|
fmt.Fprint(w, usage)
|
|
}
|