From 5fed5c07184f12ec50bf26c95290de0fa697c1bc Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Tue, 5 Feb 2019 23:29:11 +0300 Subject: [PATCH] We'd better keep -h for host --- Dockerfile | 2 +- Dockerfile.travis | 2 +- README.md | 8 ++++---- app.go | 12 ++++++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ac07a35..f3c13952 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,4 +21,4 @@ EXPOSE 53 3000 VOLUME /data ENTRYPOINT ["/AdGuardHome"] -CMD ["-o", "0.0.0.0"] \ No newline at end of file +CMD ["-h", "0.0.0.0"] \ No newline at end of file diff --git a/Dockerfile.travis b/Dockerfile.travis index af919c65..31bb339c 100644 --- a/Dockerfile.travis +++ b/Dockerfile.travis @@ -12,4 +12,4 @@ EXPOSE 53 3000 VOLUME /data ENTRYPOINT ["/AdGuardHome"] -CMD ["-o", "0.0.0.0"] \ No newline at end of file +CMD ["-h", "0.0.0.0"] \ No newline at end of file diff --git a/README.md b/README.md index d6379ae5..f1b80df1 100644 --- a/README.md +++ b/README.md @@ -127,19 +127,19 @@ You can redefine this behavior in AdGuard Home configuration file (see below). Here is a list of all available command-line arguments. ``` -$ ./AdGuardHome -h +$ ./AdGuardHome --help Usage: ./AdGuardHome [options] Options: -c, --config path to config file - -o, --host host address to bind HTTP server on + -h, --host host address to bind HTTP server on -p, --port port to serve HTTP pages on - -v, --verbose enable verbose output -s, --service service control action: status, install, uninstall, start, stop, restart -l, --logfile path to the log file. If empty, writes to stdout, if 'syslog' -- system log - -h, --help print this help + -v, --verbose enable verbose output + --help print this help ``` Please note, that the command-line arguments override settings from the configuration file. diff --git a/app.go b/app.go index 2e72e1de..39aba5c7 100644 --- a/app.go +++ b/app.go @@ -258,7 +258,7 @@ func loadOptions() options { callbackNoValue func() }{ {"config", "c", "path to config file", func(value string) { o.configFilename = value }, nil}, - {"host", "o", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil}, + {"host", "h", "host address to bind HTTP server on", func(value string) { o.bindHost = value }, nil}, {"port", "p", "port to serve HTTP pages on", func(value string) { v, err := strconv.Atoi(value) if err != nil { @@ -273,7 +273,7 @@ func loadOptions() options { o.logFile = value }, nil}, {"verbose", "v", "enable verbose output", nil, func() { o.verbose = true }}, - {"help", "h", "print this help", nil, func() { + {"help", "", "print this help", nil, func() { printHelp() os.Exit(64) }}, @@ -283,14 +283,18 @@ func loadOptions() options { fmt.Printf("%s [options]\n\n", os.Args[0]) fmt.Printf("Options:\n") for _, opt := range opts { - fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description) + if opt.shortName != "" { + fmt.Printf(" -%s, %-30s %s\n", opt.shortName, "--"+opt.longName, opt.description) + } else { + fmt.Printf(" %-34s %s\n", "--"+opt.longName, opt.description) + } } } for i := 1; i < len(os.Args); i++ { v := os.Args[i] knownParam := false for _, opt := range opts { - if v == "--"+opt.longName || v == "-"+opt.shortName { + if v == "--"+opt.longName || (opt.shortName != "" && v == "-"+opt.shortName) { if opt.callbackWithValue != nil { if i+1 >= len(os.Args) { log.Printf("ERROR: Got %s without argument\n", v)