From af0fc1b352b8f05d7922eddcfe4d7876f49127d5 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Thu, 18 Nov 2021 11:10:35 +0800 Subject: [PATCH] docs: update usage prompt --- README.md | 14 ++++++++++---- build.sh | 13 +++++++++++++ cmd/gterm/main.go | 16 ++++++++-------- 3 files changed, 31 insertions(+), 12 deletions(-) create mode 100755 build.sh diff --git a/README.md b/README.md index 45f333b..9aa65d9 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..65ef7bf --- /dev/null +++ b/build.sh @@ -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 diff --git a/cmd/gterm/main.go b/cmd/gterm/main.go index c7717df..8f1bb42 100644 --- a/cmd/gterm/main.go +++ b/cmd/gterm/main.go @@ -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() } }