From 0c6f6e92422b9c86784f45305f20cc652307546a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 14 Aug 2013 18:49:27 +0200 Subject: Reorder command line options in usage message and add separating empty lines --- src/options.c | 4 ++++ src/options.def.h | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/options.c b/src/options.c index 92ac46e..d5c823b 100644 --- a/src/options.c +++ b/src/options.c @@ -68,10 +68,12 @@ static void usage(fastd_context_t *ctx, fastd_config_t *conf) { puts("fastd (Fast and Secure Tunnelling Daemon) " FASTD_VERSION " usage:\n"); #define OR ", " +#define SEPARATOR puts("") #define OPTION(func, options, message) print_usage(" " options, message) #define OPTION_ARG(func, options, arg, message) print_usage(" " options " " arg, message) #include "options.def.h" #undef OR +#undef SEPARATOR #undef OPTION #undef OPTION_ARG @@ -335,6 +337,7 @@ void fastd_config_handle_options(fastd_context_t *ctx, fastd_config_t *conf, int while (i < argc) { #define OR , +#define SEPARATOR do {} while (false) #define OPTION(func, options, message) \ ({ \ if(config_match(argv[i], options, NULL)) { \ @@ -355,6 +358,7 @@ void fastd_config_handle_options(fastd_context_t *ctx, fastd_config_t *conf, int }) #include "options.def.h" #undef OR +#undef SEPARATOR #undef OPTION #undef OPTION_ARG diff --git a/src/options.def.h b/src/options.def.h index 0b623d4..73ce1c5 100644 --- a/src/options.def.h +++ b/src/options.def.h @@ -1,17 +1,21 @@ OPTION(usage, "--help" OR "-h", "Shows this help text"); OPTION(version, "--version" OR "-v", "Shows the fastd version"); OPTION(option_daemon, "--daemon" OR "-d", "Runs fastd in the background"); +OPTION_ARG(option_pid_file, "--pid-file", "", "Writes fastd's PID to the specified file"); +SEPARATOR; +OPTION_ARG(option_config, "--config" OR "-c", "", "Loads a config file"); +OPTION_ARG(option_config_peer, "--config-peer", "", "Loads a config file for a single peer"); +OPTION_ARG(option_config_peer_dir, "--config-peer-dir", "", "Loads all files from a directory as peer configs"); +SEPARATOR; OPTION_ARG(option_user, "--user", "", "Sets the user to run fastd as"); OPTION_ARG(option_group, "--group", "", "Sets the group to run fastd as"); -OPTION_ARG(option_pid_file, "--pid-file", "", "Writes fastd's PID to the specified file"); +SEPARATOR; OPTION_ARG(option_log_level, "--log-level", "error|warn|info|verbose|debug", "Sets the stderr log level; default is info, if no alternative log destination is configured"); OPTION_ARG(option_syslog_level, "--syslog-level", "error|warn|info|verbose|debug", "Sets the log level for syslog output; default is not to use syslog"); OPTION_ARG(option_syslog_ident, "--syslog-ident", "", "Sets the syslog identification; default is 'fastd'"); OPTION(option_hide_ip_addresses, "--hide-ip-addresses", "Hides IP addresses in log output"); OPTION(option_hide_mac_addresses, "--hide-mac-addresses", "Hides MAC addresses in log output"); -OPTION_ARG(option_config, "--config" OR "-c", "", "Loads a config file"); -OPTION_ARG(option_config_peer, "--config-peer", "", "Loads a config file for a single peer"); -OPTION_ARG(option_config_peer_dir, "--config-peer-dir", "", "Loads all files from a directory as peer configs"); +SEPARATOR; OPTION_ARG(option_mode, "--mode" OR "-m", "tap|tun", "Sets the mode of the interface"); OPTION_ARG(option_interface, "--interface" OR "-i", "", "Sets the name of the TUN/TAP interface to use"); OPTION_ARG(option_mtu, "--mtu" OR "-M", "", "Sets the MTU; must be at least 576"); @@ -19,6 +23,7 @@ OPTION_ARG(option_bind, "--bind" OR "-b", "
[:]", "Sets the bind a OPTION_ARG(option_protocol, "--protocol" OR "-p", "", "Sets the protocol"); OPTION_ARG(option_method, "--method", "", "Sets the encryption method"); OPTION(option_forward, "--forward", "Enables forwarding of packets between peers; read the documentation before use!"); +SEPARATOR; OPTION_ARG(option_on_pre_up, "--on-pre-up", "", "Sets a shell command to execute before interface creation"); OPTION_ARG(option_on_up, "--on-up", "", "Sets a shell command to execute after interface creation"); OPTION_ARG(option_on_down, "--on-down", "", "Sets a shell command to execute before interface destruction"); @@ -26,6 +31,7 @@ OPTION_ARG(option_on_post_down, "--on-post-down", "", "Sets a shell com OPTION_ARG(option_on_establish, "--on-establish", "", "Sets a shell command to execute when a new connection is established"); OPTION_ARG(option_on_disestablish, "--on-disestablish", "", "Sets a shell command to execute when a connection is lost"); OPTION_ARG(option_on_verify, "--on-verify", "", "Sets a shell command to execute to check a connection attempt by an unknown peer"); +SEPARATOR; OPTION(option_generate_key, "--generate-key", "Generates a new keypair"); OPTION(option_show_key, "--show-key", "Shows the public key corresponding to the configured secret"); OPTION(option_machine_readable, "--machine-readable", "Suppresses output of explaining text in the --show-key and --generate-key commands"); -- cgit v1.2.3