44 lines
803 B
Go
44 lines
803 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func RunExp(args ...string) error {
|
|
name, args := ParseCommandName(args)
|
|
|
|
// 从参数中解析出命令
|
|
switch name {
|
|
case "", "help":
|
|
return RunExpHelp(args...)
|
|
case "list":
|
|
return RunExpList(args...)
|
|
case "get":
|
|
return RunExpGet(args...)
|
|
default:
|
|
err := fmt.Errorf(`unknown command "%s"`+"\n"+`Run 'saastool exp help' for usage`, name)
|
|
fmt.Fprintln(os.Stderr, err)
|
|
|
|
return err
|
|
}
|
|
}
|
|
|
|
func RunExpHelp(args ...string) error {
|
|
fmt.Println(strings.TrimSpace(expUsage))
|
|
return nil
|
|
}
|
|
|
|
const expUsage = `
|
|
Usage: saastoola exp COMMAND [OPTIONS]
|
|
|
|
Commands:
|
|
list List exps
|
|
get Get exp report
|
|
|
|
"help" is the default command.
|
|
|
|
Use "saastool exp COMMAND -help" for more information about a command.
|
|
`
|