Skip to content

Commit

Permalink
help goes to stdout and exits with 0, remove incorrect versioning fro…
Browse files Browse the repository at this point in the history
…m help
  • Loading branch information
jpillora committed Nov 16, 2020
1 parent 2d6c5cb commit f04afd2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ and then visit [localhost:3000](http://localhost:3000/), we should see a directo
or use https://github.com/jpillora/md-tmpl
with $ md-tmpl -w README.md -->

<!--tmpl,code=plain:echo "$ chisel --help" && go run main.go --help | cat -->
<!--tmpl,code=plain:echo "$ chisel --help" && go run main.go --help | sed 's#0.0.0-src (go1\..*)#X.Y.Z#' -->
``` plain
$ chisel --help
Usage: chisel [command] [--help]
Version: 0.0.0-src (go1.14.6)
Version: X.Y.Z
Commands:
server - runs chisel in server mode
Expand All @@ -87,7 +87,7 @@ $ chisel --help
<!--/tmpl-->


<!--tmpl,code=plain:echo "$ chisel server --help" && go run main.go server --help | cat -->
<!--tmpl,code=plain:echo "$ chisel server --help" && go run main.go server --help | cat | sed 's#0.0.0-src (go1\..*)#X.Y.Z#' -->
``` plain
$ chisel server --help
Expand Down Expand Up @@ -173,7 +173,7 @@ $ chisel server --help
a SIGHUP to short-circuit the client reconnect timer
Version:
0.0.0-src (go1.14.6)
X.Y.Z
Read more:
https://github.com/jpillora/chisel
Expand All @@ -182,7 +182,7 @@ $ chisel server --help
<!--/tmpl-->


<!--tmpl,code=plain:echo "$ chisel client --help" && go run main.go client --help | cat -->
<!--tmpl,code=plain:echo "$ chisel client --help" && go run main.go client --help | sed 's#0.0.0-src (go1\..*)#X.Y.Z#' -->
``` plain
$ chisel client --help
Expand Down Expand Up @@ -244,9 +244,12 @@ $ chisel client --help
Options:
--fingerprint, A *strongly recommended* fingerprint (base64 encoded SHA256)
string to perform host-key validation against the server's public key.
Fingerprint mismatches will close the connection.
--fingerprint, A *strongly recommended* fingerprint string
to perform host-key validation against the server's public key.
Fingerprint mismatches will close the connection.
Fingerprints are generated by hashing the ECDSA public key using
SHA256 and encoding the result in base64.
Fingerprints must be 44 characters containing a trailing equals (=).
--auth, An optional username and password (client authentication)
in the form: "<user>:<pass>". These credentials are compared to
Expand Down Expand Up @@ -308,7 +311,7 @@ $ chisel client --help
a SIGHUP to short-circuit the client reconnect timer
Version:
0.0.0-src (go1.14.6)
X.Y.Z
Read more:
https://github.com/jpillora/chisel
Expand Down
17 changes: 10 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func main() {

if *version || *v {
fmt.Println(chshare.BuildVersion)
os.Exit(1)
os.Exit(0)
}

args := flag.Args()
Expand All @@ -60,8 +60,8 @@ func main() {
case "client":
client(args)
default:
fmt.Fprintf(os.Stderr, help)
os.Exit(1)
fmt.Print(help)
os.Exit(0)
}
}

Expand Down Expand Up @@ -190,7 +190,7 @@ func server(args []string) {

flags.Usage = func() {
fmt.Print(serverHelp)
os.Exit(1)
os.Exit(0)
}
flags.Parse(args)

Expand Down Expand Up @@ -328,9 +328,12 @@ var clientHelp = `
Options:
--fingerprint, A *strongly recommended* fingerprint (base64 encoded SHA256) string
--fingerprint, A *strongly recommended* fingerprint string
to perform host-key validation against the server's public key.
Fingerprint mismatches will close the connection.
Fingerprint mismatches will close the connection.
Fingerprints are generated by hashing the ECDSA public key using
SHA256 and encoding the result in base64.
Fingerprints must be 44 characters containing a trailing equals (=).
--auth, An optional username and password (client authentication)
in the form: "<user>:<pass>". These credentials are compared to
Expand Down Expand Up @@ -400,7 +403,7 @@ func client(args []string) {
verbose := flags.Bool("v", false, "")
flags.Usage = func() {
fmt.Print(clientHelp)
os.Exit(1)
os.Exit(0)
}
flags.Parse(args)
//pull out options, put back remaining args
Expand Down

0 comments on commit f04afd2

Please sign in to comment.