Skip to content

Commit

Permalink
update cli for opts v1
Browse files Browse the repository at this point in the history
  • Loading branch information
jpillora committed Jul 29, 2019
1 parent b9cc0bc commit 0e15e52
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 32 deletions.
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,29 @@ For more features, see the [Configuration](#Configuration) file
```
$ webproc --help
Usage: webproc [options] args...
args can be either a command with arguments or a webproc file
Options:
--host, -h listening interface
--port, -p listening port (env PORT)
--user, -u basic auth username (env USER)
--pass basic auth password (env PASS)
--on-exit, -o process exit action (default ignore)
--config, -c comma-separated list of configuration files
--help
--version, -v
Version:
0.0.0-src
Read more:
https://github.com/jpillora/webproc
Usage: webproc [options] <arg> [arg] ...
args can be either a command with arguments or a webproc file
Options:
--host, -h listening interface (default 0.0.0.0)
--port, -p listening port (default 8080, env PORT)
--user, -u basic auth username (env HTTP_USER)
--pass basic auth password (env HTTP_PASS)
--allowed-ip, -a allowed ip or cidr block (allows multiple)
--log, -l log mode (must be 'webui' or 'proxy' or 'both' defaults to 'both')
--on-exit, -o process exit action (default ignore)
--configuration-file, -c configuration file (allows multiple)
--restart-timeout, -r restart timeout controls when to perform a force kill (default 30s)
--max-lines, -m maximum number of log lines to show in webui (default 5000)
--version, -v display version
--help display help
Version:
0.0.0-src
Read more:
https://github.com/jpillora/webproc
```

Expand Down
25 changes: 13 additions & 12 deletions agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ const (
OnExitProxy OnExit = "proxy"
)

//Config is shared for both toml unmarshalling and opts CLI generation
//Config is shared for both toml unmarshalling and opts CLI generation.
//Defaults are applied on ValidateConfig.
type Config struct {
Host string `help:"listening interface"`
Port int `help:"listening port" env:"PORT"`
User string `help:"basic auth username" env:"HTTP_USER"`
Pass string `help:"basic auth password" env:"HTTP_PASS"`
AllowedIPs []string `opts:"-"`
ProgramArgs []string `type:"arglist" min:"1" name:"args" help:"args can be either a command with arguments or a webproc file"`
Log Log `opts:"-"`
OnExit OnExit `help:"process exit action" default:"ignore"`
ConfigurationFiles []string `name:"config" type:"commalist" help:"comma-separated list of configuration files"`
RestartTimeout Duration `opts:"-"`
MaxLines int `help:"maximum number of log lines to show in webui" default:"5000"`
Host string `opts:"help=listening interface, default=0.0.0.0"`
Port int `opts:"help=listening port, default=8080, env=PORT"`
User string `opts:"help=basic auth username, env=HTTP_USER"`
Pass string `opts:"help=basic auth password, env=HTTP_PASS"`
AllowedIPs []string `opts:"name=allowed-ip, help=allowed ip or cidr block"`
ProgramArgs []string `opts:"mode=arg, name=arg, help=args can be either a command with arguments or a webproc file, min=1"`
Log Log `opts:"help=log mode (must be 'webui' or 'proxy' or 'both' defaults to 'both')"`
OnExit OnExit `opts:"help=process exit action, default=ignore"`
ConfigurationFiles []string `opts:"mode=flag, help=writable configuration file"`
RestartTimeout Duration `opts:"help=restart timeout controls when to perform a force kill, default=30s"`
MaxLines int `opts:"help=maximum number of log lines to show in webui, default=5000"`
}

func LoadConfig(path string, c *Config) error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/jpillora/cookieauth v0.0.0-20181130112401-3b2db39b9d2c
github.com/jpillora/eventsource v0.0.0-20170920003432-7ed8c999e167 // indirect
github.com/jpillora/ipfilter v0.0.0-20180911073613-0cbe4c7e01b1
github.com/jpillora/opts v0.0.0-20160806153215-3f7962811f23
github.com/jpillora/opts v1.1.0
github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82
github.com/jpillora/sizestr v0.0.0-20160130011556-e2ea2fa42fb9 // indirect
github.com/jpillora/velox v0.0.0-20180825063758-42845d323220
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ github.com/elithrar/simple-scrypt v1.3.0 h1:KIlOlxdoQf9JWKl5lMAJ28SY2URB0XTRDn2T
github.com/elithrar/simple-scrypt v1.3.0/go.mod h1:U2XQRI95XHY0St410VE3UjT7vuKb1qPwrl/EJwEqnZo=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/jpillora/ansi v0.0.0-20170202005112-f496b27cd669 h1:l5rH/CnVVu+HPxjtxjM90nHrm4nov3j3RF9/62UjgLs=
Expand All @@ -22,6 +26,8 @@ github.com/jpillora/ipfilter v0.0.0-20180911073613-0cbe4c7e01b1 h1:uVa/fnx/kuryY
github.com/jpillora/ipfilter v0.0.0-20180911073613-0cbe4c7e01b1/go.mod h1:cVpzWD9ypibSo5IdbBqJf9dVKW/pPeLGx0q+4X7k5rk=
github.com/jpillora/opts v0.0.0-20160806153215-3f7962811f23 h1:Oba9AG0bpHgp5FZFG+XfiNDlFX6tLO0AWCMe/YJR0GM=
github.com/jpillora/opts v0.0.0-20160806153215-3f7962811f23/go.mod h1:8/sC6XyMKHq/ybiU9Oqc1i0tDjFA/6otW7+Ha/qtnfo=
github.com/jpillora/opts v1.1.0 h1:eP4c8yn68iN4OgQ/6nTAWd+obufJOwUvAqW7dYzvCwA=
github.com/jpillora/opts v1.1.0/go.mod h1:7p7X/vlpKZmtaDFYKs956EujFqA6aCrOkcCaS6UBcR4=
github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82 h1:7ufdyC3aMxFcCv+ABZy/dmIVGKFoGNBCqOgLYPIckD8=
github.com/jpillora/requestlog v0.0.0-20181015073026-df8817be5f82/go.mod h1:w8buj+yNfmLEP0ENlbG/FRnK6bVmuhqXnukYCs9sDvY=
github.com/jpillora/sizestr v0.0.0-20160130011556-e2ea2fa42fb9 h1:0c9jcgBtHRtDU//jTrcCgWG6UHjMZytiq/3WhraNgUM=
Expand All @@ -38,6 +44,8 @@ github.com/naoina/toml v0.1.1 h1:PT/lllxVVN0gzzSqSlHEmP8MJB4MY2U7STGxiouV4X8=
github.com/naoina/toml v0.1.1/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E=
github.com/oschwald/maxminddb-golang v1.3.0 h1:oTh8IBSj10S5JNlUDg5WjJ1QdBMdeaZIkPEVfESSWgE=
github.com/oschwald/maxminddb-golang v1.3.0/go.mod h1:3jhIUymTJ5VREKyIhWm66LJiQt04F0UCDdodShpjWsY=
github.com/posener/complete v1.2.2-0.20190308074557-af07aa5181b3 h1:GqpA1/5oN1NgsxoSA4RH0YWTaqvUlQNeOpHXD/JRbOQ=
github.com/posener/complete v1.2.2-0.20190308074557-af07aa5181b3/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E=
github.com/rakyll/statik v0.1.5 h1:Ly2UjURzxnsSYS0zI50fZ+srA+Fu7EbpV5hglvJvJG0=
github.com/rakyll/statik v0.1.5/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce h1:fb190+cK2Xz/dvi9Hv8eCYJYvIGUTN2/KLq1pT6CjEc=
Expand Down

0 comments on commit 0e15e52

Please sign in to comment.