Pull request: home: fix help

Merge in DNS/adguard-home from fix-help to master

Updates #2893.

Squashed commit of the following:

commit df84e0968c036ad0d1978dc6170214058ef07255
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Apr 13 14:51:53 2021 +0300

    home: fix help
This commit is contained in:
Eugene Burkov 2021-04-13 15:13:28 +03:00
parent 48d702f76a
commit ab85ad5a55
1 changed files with 14 additions and 14 deletions

View File

@ -94,7 +94,7 @@ func boolSliceOrNil(b bool) []string {
var args []arg var args []arg
var configArg = arg{ var configArg = arg{
"Path to the config file", "Path to the config file.",
"config", "c", "config", "c",
func(o options, v string) (options, error) { o.configFilename = v; return o, nil }, func(o options, v string) (options, error) { o.configFilename = v; return o, nil },
nil, nil,
@ -103,21 +103,21 @@ var configArg = arg{
} }
var workDirArg = arg{ var workDirArg = arg{
"Path to the working directory", "Path to the working directory.",
"work-dir", "w", "work-dir", "w",
func(o options, v string) (options, error) { o.workDir = v; return o, nil }, nil, nil, func(o options, v string) (options, error) { o.workDir = v; return o, nil }, nil, nil,
func(o options) []string { return stringSliceOrNil(o.workDir) }, func(o options) []string { return stringSliceOrNil(o.workDir) },
} }
var hostArg = arg{ var hostArg = arg{
"Host address to bind HTTP server on", "Host address to bind HTTP server on.",
"host", "h", "host", "h",
func(o options, v string) (options, error) { o.bindHost = net.ParseIP(v); return o, nil }, nil, nil, func(o options, v string) (options, error) { o.bindHost = net.ParseIP(v); return o, nil }, nil, nil,
func(o options) []string { return ipSliceOrNil(o.bindHost) }, func(o options) []string { return ipSliceOrNil(o.bindHost) },
} }
var portArg = arg{ var portArg = arg{
"Port to serve HTTP pages on", "Port to serve HTTP pages on.",
"port", "p", "port", "p",
func(o options, v string) (options, error) { func(o options, v string) (options, error) {
var err error var err error
@ -136,7 +136,7 @@ var portArg = arg{
} }
var serviceArg = arg{ var serviceArg = arg{
"Service control action: status, install, uninstall, start, stop, restart, reload (configuration)", "Service control action: status, install, uninstall, start, stop, restart, reload (configuration).",
"service", "s", "service", "s",
func(o options, v string) (options, error) { func(o options, v string) (options, error) {
o.serviceControlAction = v o.serviceControlAction = v
@ -146,56 +146,56 @@ var serviceArg = arg{
} }
var logfileArg = arg{ var logfileArg = arg{
"Path to log file. If empty: write to stdout; if 'syslog': write to system log", "Path to log file. If empty: write to stdout; if 'syslog': write to system log.",
"logfile", "l", "logfile", "l",
func(o options, v string) (options, error) { o.logFile = v; return o, nil }, nil, nil, func(o options, v string) (options, error) { o.logFile = v; return o, nil }, nil, nil,
func(o options) []string { return stringSliceOrNil(o.logFile) }, func(o options) []string { return stringSliceOrNil(o.logFile) },
} }
var pidfileArg = arg{ var pidfileArg = arg{
"Path to a file where PID is stored", "Path to a file where PID is stored.",
"pidfile", "", "pidfile", "",
func(o options, v string) (options, error) { o.pidFile = v; return o, nil }, nil, nil, func(o options, v string) (options, error) { o.pidFile = v; return o, nil }, nil, nil,
func(o options) []string { return stringSliceOrNil(o.pidFile) }, func(o options) []string { return stringSliceOrNil(o.pidFile) },
} }
var checkConfigArg = arg{ var checkConfigArg = arg{
"Check configuration and exit", "Check configuration and exit.",
"check-config", "", "check-config", "",
nil, func(o options) (options, error) { o.checkConfig = true; return o, nil }, nil, nil, func(o options) (options, error) { o.checkConfig = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.checkConfig) }, func(o options) []string { return boolSliceOrNil(o.checkConfig) },
} }
var noCheckUpdateArg = arg{ var noCheckUpdateArg = arg{
"Don't check for updates", "Don't check for updates.",
"no-check-update", "", "no-check-update", "",
nil, func(o options) (options, error) { o.disableUpdate = true; return o, nil }, nil, nil, func(o options) (options, error) { o.disableUpdate = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableUpdate) }, func(o options) []string { return boolSliceOrNil(o.disableUpdate) },
} }
var disableMemoryOptimizationArg = arg{ var disableMemoryOptimizationArg = arg{
"Disable memory optimization", "Disable memory optimization.",
"no-mem-optimization", "", "no-mem-optimization", "",
nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil, nil, func(o options) (options, error) { o.disableMemoryOptimization = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) }, func(o options) []string { return boolSliceOrNil(o.disableMemoryOptimization) },
} }
var verboseArg = arg{ var verboseArg = arg{
"Enable verbose output", "Enable verbose output.",
"verbose", "v", "verbose", "v",
nil, func(o options) (options, error) { o.verbose = true; return o, nil }, nil, nil, func(o options) (options, error) { o.verbose = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.verbose) }, func(o options) []string { return boolSliceOrNil(o.verbose) },
} }
var glinetArg = arg{ var glinetArg = arg{
"Run in GL-Inet compatibility mode", "Run in GL-Inet compatibility mode.",
"glinet", "", "glinet", "",
nil, func(o options) (options, error) { o.glinetMode = true; return o, nil }, nil, nil, func(o options) (options, error) { o.glinetMode = true; return o, nil }, nil,
func(o options) []string { return boolSliceOrNil(o.glinetMode) }, func(o options) []string { return boolSliceOrNil(o.glinetMode) },
} }
var versionArg = arg{ var versionArg = arg{
description: "Show the version and exit. Show more detailed version description with -v", description: "Show the version and exit. Show more detailed version description with -v.",
longName: "version", longName: "version",
shortName: "", shortName: "",
updateWithValue: nil, updateWithValue: nil,
@ -216,7 +216,7 @@ var versionArg = arg{
} }
var helpArg = arg{ var helpArg = arg{
"Print this help", "Print this help.",
"help", "", "help", "",
nil, nil, func(o options, exec string) (effect, error) { nil, nil, func(o options, exec string) (effect, error) {
return func() error { _ = printHelp(exec); os.Exit(64); return nil }, nil return func() error { _ = printHelp(exec); os.Exit(64); return nil }, nil