docs: update usage prompt

master
Evan Chen 2021-11-18 11:10:35 +08:00
parent 2fecf640de
commit af0fc1b352
3 changed files with 31 additions and 12 deletions

View File

@ -9,14 +9,20 @@ Usage: gterm [options]
address to bind (default ":8000")
-allow string
restrict ip
-arg value
additional args to pass to cmd, multiple args can be passed, ex. -arg a -arg b
-dev
is development mode
set the system to development mode
-dir string
the working dir that the shell will start from
-log-level int
log level (default 9)
log level, error:1 debug:2 warn:4 info:8 (default 9)
-name string
the application title (default "gterm")
the application name (default "gterm")
-profile
print default profile, could be invoked with <(..)
-shell string
the shell behind (default "bash")
the shell to use (default "bash")
-v show version
```

13
build.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
VERSION=$(git describe --tags --abbrev=0)
BUILD=$(git rev-parse --short HEAD)
PROJ=gterm
DIST=dist
LDFLAGS="-ldflags \"-X main.Version=${VERSION} -X main.Build=${BUILD} -w -s\""
BIN_FILENAME="${PROJ}"
CMD="CGO_ENABLED=0 go build ${LDFLAGS} -o ${DIST}/${BIN_FILENAME} cmd/gterm/main.go"
echo "${CMD}"
eval $CMD

View File

@ -40,19 +40,19 @@ var (
)
func init() {
flag.StringVar(&flagAppName, "name", "gterm", "the application title")
flag.StringVar(&flagAppName, "name", "gterm", "the application name")
flag.StringVar(&flagAddr, "addr", ":8000", "address to bind")
flag.StringVar(&flagShell, "shell", "bash", "the shell behind")
flag.StringVar(&flagDir, "dir", ".", "the working dir")
flag.Var(&flagArgs, "arg", "additional args to pass to cmd")
flag.BoolVar(&flagDev, "dev", false, "is development mode")
flag.IntVar(&flagLogLevel, "log-level", 9, "log level")
flag.StringVar(&flagShell, "shell", "bash", "the shell to use")
flag.StringVar(&flagDir, "dir", "", "the working dir that the shell will start from")
flag.Var(&flagArgs, "arg", "additional args to pass to cmd, multiple args can be passed, ex. -arg a -arg b")
flag.BoolVar(&flagDev, "dev", false, "set the system to development mode")
flag.IntVar(&flagLogLevel, "log-level", 9, "log level, error:1 debug:2 warn:4 info:8")
flag.StringVar(&flagAllowIP, "allow", "", "restrict ip")
flag.BoolVar(&flagProfile, "profile", false, "print default profile, invoked with <(..)")
flag.BoolVar(&flagProfile, "profile", false, "print default profile, could be invoked with <(..)")
flag.BoolVar(&flagVer, "v", false, "show version")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: gterm [options] [args...]\n")
fmt.Fprintf(os.Stderr, "Usage: gterm [options]\n")
flag.PrintDefaults()
}
}