clean up options

make sure we can use -v for verbose mode
This commit is contained in:
Wim Taymans 2020-04-02 14:34:02 +02:00
parent 1fd5be7101
commit b87c0a9270
8 changed files with 102 additions and 104 deletions

View file

@ -63,14 +63,14 @@ struct data {
#define OPTIONS "hvr:f:q:"
static const struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'},
{ "help", no_argument, NULL, 'h'},
{ "verbose", no_argument, NULL, 'v'},
{"rate", required_argument, NULL, 'r' },
{"format", required_argument, NULL, 'f' },
{"quality", required_argument, NULL, 'q' },
{ "rate", required_argument, NULL, 'r' },
{ "format", required_argument, NULL, 'f' },
{ "quality", required_argument, NULL, 'q' },
{NULL, 0, NULL, 0 }
{ NULL, 0, NULL, 0 }
};
static void show_usage(const char *name, bool is_error)

View file

@ -43,11 +43,11 @@ static void do_quit(void *data, int signal_number)
static void show_help(const char *name)
{
fprintf(stdout, "%s [options]\n"
" -h, --help Show this help\n"
" -v, --version Show version\n"
" -n, --name Daemon name (Default %s)\n",
name,
daemon_name);
" -h, --help Show this help\n"
" --version Show version\n"
" -n, --name Daemon name (Default %s)\n",
name,
daemon_name);
}
int main(int argc, char *argv[])
@ -58,21 +58,22 @@ int main(int argc, char *argv[])
struct pw_properties *properties;
char *err = NULL;
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'v'},
{"name", 1, NULL, 'n'},
{NULL, 0, NULL, 0}
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "name", required_argument, NULL, 'n' },
{ NULL, 0, NULL, 0}
};
int c, res;
pw_init(&argc, &argv);
while ((c = getopt_long(argc, argv, "hvn:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "hVn:", long_options, NULL)) != -1) {
switch (c) {
case 'h' :
show_help(argv[0]);
return 0;
case 'v' :
case 'V' :
fprintf(stdout, "%s\n"
"Compiled with libpipewire %s\n"
"Linked with libpipewire %s\n",

View file

@ -1726,7 +1726,7 @@ static void show_help(const char *name)
fprintf(stdout, "%s [options]\n"
" -h, --help Show this help\n"
" -v, --version Show version\n"
" --version Show version\n"
" -e, --enabled Enabled options (default '%s')\n"
" -d, --disabled Disabled options (default '%s')\n"
" -p, --properties Extra properties as 'key=value { key=value }'\n",
@ -1749,24 +1749,24 @@ int main(int argc, char *argv[])
const char *opt_disabled = DEFAULT_DISABLED;
const char *opt_properties = NULL;
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'v'},
{"enabled", 1, NULL, 'e'},
{"disabled", 1, NULL, 'd'},
{"properties", 1, NULL, 'p'},
{NULL, 0, NULL, 0}
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "enabled", required_argument, NULL, 'e' },
{ "disabled", required_argument, NULL, 'd' },
{ "properties", required_argument, NULL, 'p' },
{ NULL, 0, NULL, 0}
};
size_t i;
const struct spa_dict_item *item;
pw_init(&argc, &argv);
while ((c = getopt_long(argc, argv, "hve:d:p:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "hVe:d:p:", long_options, NULL)) != -1) {
switch (c) {
case 'h':
show_help(argv[0]);
return 0;
case 'v':
case 'V':
fprintf(stdout, "%s\n"
"Compiled with libpipewire %s\n"
"Linked with libpipewire %s\n",

View file

@ -863,32 +863,32 @@ enum {
};
static const struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, OPT_VERSION},
{"verbose", no_argument, NULL, 'v'},
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, OPT_VERSION},
{ "verbose", no_argument, NULL, 'v' },
{"record", no_argument, NULL, 'r'},
{"playback", no_argument, NULL, 's'},
{"midi", no_argument, NULL, 'm'},
{ "record", no_argument, NULL, 'r' },
{ "playback", no_argument, NULL, 's' },
{ "midi", no_argument, NULL, 'm' },
{"remote", required_argument, NULL, 'R'},
{ "remote", required_argument, NULL, 'R' },
{"media-type", required_argument, NULL, OPT_MEDIA_TYPE },
{"media-category", required_argument, NULL, OPT_MEDIA_CATEGORY },
{"media-role", required_argument, NULL, OPT_MEDIA_ROLE },
{"target", required_argument, NULL, OPT_TARGET },
{"latency", required_argument, NULL, OPT_LATENCY },
{ "media-type", required_argument, NULL, OPT_MEDIA_TYPE },
{ "media-category", required_argument, NULL, OPT_MEDIA_CATEGORY },
{ "media-role", required_argument, NULL, OPT_MEDIA_ROLE },
{ "target", required_argument, NULL, OPT_TARGET },
{ "latency", required_argument, NULL, OPT_LATENCY },
{"rate", required_argument, NULL, OPT_RATE },
{"channels", required_argument, NULL, OPT_CHANNELS },
{"channel-map", required_argument, NULL, OPT_CHANNELMAP },
{"format", required_argument, NULL, OPT_FORMAT },
{"volume", required_argument, NULL, OPT_VOLUME },
{"quality", required_argument, NULL, 'q' },
{ "rate", required_argument, NULL, OPT_RATE },
{ "channels", required_argument, NULL, OPT_CHANNELS },
{ "channel-map", required_argument, NULL, OPT_CHANNELMAP },
{ "format", required_argument, NULL, OPT_FORMAT },
{ "volume", required_argument, NULL, OPT_VOLUME },
{ "quality", required_argument, NULL, 'q' },
{"list-targets", no_argument, NULL, OPT_LIST_TARGETS },
{ "list-targets", no_argument, NULL, OPT_LIST_TARGETS },
{NULL, 0, NULL, 0 }
{ NULL, 0, NULL, 0 }
};
static void show_usage(const char *name, bool is_error)
@ -902,6 +902,7 @@ static void show_usage(const char *name, bool is_error)
fprintf(fp,
" -h, --help Show this help\n"
" --version Show version\n"
" -v, --verbose Enable verbose operations\n"
"\n");
fprintf(fp,
@ -945,10 +946,6 @@ static void show_usage(const char *name, bool is_error)
" -m, --midi Midi mode\n"
"\n");
}
fprintf(fp,
" -v, --verbose Enable verbose operations\n"
"\n");
}
static int midi_play(struct data *d, void *src, unsigned int n_frames)

View file

@ -2748,11 +2748,11 @@ static void do_quit(void *data, int signal_number)
static void show_help(struct data *data, const char *name)
{
fprintf(stdout, "%s [options] [command]\n"
" -h, --help Show this help\n"
" -v, --version Show version\n"
" -d, --daemon Start as daemon (Default false)\n"
" -r, --remote Remote daemon name\n\n",
name);
" -h, --help Show this help\n"
" --version Show version\n"
" -d, --daemon Start as daemon (Default false)\n"
" -r, --remote Remote daemon name\n\n",
name);
do_help(data, "help", "", NULL);
}
@ -2765,22 +2765,22 @@ int main(int argc, char *argv[])
char *error;
bool daemon = false;
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'v'},
{"daemon", 0, NULL, 'd'},
{"remote", 1, NULL, 'r'},
{NULL, 0, NULL, 0}
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "daemon", no_argument, NULL, 'd' },
{ "remote", required_argument, NULL, 'r' },
{ NULL, 0, NULL, 0}
};
int c, i;
pw_init(&argc, &argv);
while ((c = getopt_long(argc, argv, "hvdr:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "hVdr:", long_options, NULL)) != -1) {
switch (c) {
case 'h':
show_help(&data, argv[0]);
return 0;
case 'v':
case 'V':
fprintf(stdout, "%s\n"
"Compiled with libpipewire %s\n"
"Linked with libpipewire %s\n",

View file

@ -746,15 +746,15 @@ static void do_quit(void *data, int signal_number)
static void show_help(const char *name)
{
fprintf(stdout, "%s [options]\n"
" -h, --help Show this help\n"
" -v, --version Show version\n"
" -a, --all Show all object types\n"
" -s, --smart Show linked objects only\n"
" -d, --detail Show all object properties\n"
" -r, --remote Remote daemon name\n"
" -o, --output Output file (Default %s)\n",
name,
DEFAULT_DOT_PATH);
" -h, --help Show this help\n"
" --version Show version\n"
" -a, --all Show all object types\n"
" -s, --smart Show linked objects only\n"
" -d, --detail Show all object properties\n"
" -r, --remote Remote daemon name\n"
" -o, --output Output file (Default %s)\n",
name,
DEFAULT_DOT_PATH);
}
int main(int argc, char *argv[])
@ -764,25 +764,25 @@ int main(int argc, char *argv[])
const char *opt_remote = NULL;
const char *dot_path = DEFAULT_DOT_PATH;
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'v'},
{"all", 0, NULL, 'a'},
{"smart", 0, NULL, 's'},
{"detail", 0, NULL, 'd'},
{"remote", 1, NULL, 'r'},
{"output", 1, NULL, 'o'},
{NULL, 0, NULL, 0}
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "all", no_argument, NULL, 'a' },
{ "smart", no_argument, NULL, 's' },
{ "detail", no_argument, NULL, 'd' },
{ "remote", required_argument, NULL, 'r' },
{ "output", required_argument, NULL, 'o' },
{ NULL, 0, NULL, 0}
};
int c;
pw_init(&argc, &argv);
while ((c = getopt_long(argc, argv, "hvasdr:o:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "hVasdr:o:", long_options, NULL)) != -1) {
switch (c) {
case 'h' :
show_help(argv[0]);
return 0;
case 'v' :
case 'V' :
fprintf(stdout, "%s\n"
"Compiled with libpipewire %s\n"
"Linked with libpipewire %s\n",

View file

@ -682,10 +682,10 @@ static void do_quit(void *data, int signal_number)
static void show_help(const char *name)
{
fprintf(stdout, "%s [options]\n"
" -h, --help Show this help\n"
" -v, --version Show version\n"
" -r, --remote Remote daemon name\n",
name);
" -h, --help Show this help\n"
" --version Show version\n"
" -r, --remote Remote daemon name\n",
name);
}
int main(int argc, char *argv[])
@ -694,21 +694,21 @@ int main(int argc, char *argv[])
struct pw_loop *l;
const char *opt_remote = NULL;
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'v'},
{"remote", 1, NULL, 'r'},
{NULL, 0, NULL, 0}
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "remote", required_argument, NULL, 'r' },
{ NULL, 0, NULL, 0}
};
int c;
pw_init(&argc, &argv);
while ((c = getopt_long(argc, argv, "hvr:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "hVr:", long_options, NULL)) != -1) {
switch (c) {
case 'h':
show_help(argv[0]);
return 0;
case 'v':
case 'V':
fprintf(stdout, "%s\n"
"Compiled with libpipewire %s\n"
"Linked with libpipewire %s\n",

View file

@ -541,12 +541,12 @@ static void do_quit(void *data, int signal_number)
static void show_help(const char *name)
{
fprintf(stdout, "%s [options]\n"
" -h, --help Show this help\n"
" -v, --version Show version\n"
" -r, --remote Remote daemon name\n"
" -o, --output Profiler output name (default \"%s\")\n",
name,
DEFAULT_FILENAME);
" -h, --help Show this help\n"
" --version Show version\n"
" -r, --remote Remote daemon name\n"
" -o, --output Profiler output name (default \"%s\")\n",
name,
DEFAULT_FILENAME);
}
int main(int argc, char *argv[])
@ -556,22 +556,22 @@ int main(int argc, char *argv[])
const char *opt_remote = NULL;
const char *opt_output = DEFAULT_FILENAME;
static const struct option long_options[] = {
{"help", 0, NULL, 'h'},
{"version", 0, NULL, 'v'},
{"remote", 1, NULL, 'r'},
{"output", 1, NULL, 'o'},
{NULL, 0, NULL, 0}
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ "remote", required_argument, NULL, 'r' },
{ "output", required_argument, NULL, 'o' },
{ NULL, 0, NULL, 0}
};
int c;
pw_init(&argc, &argv);
while ((c = getopt_long(argc, argv, "hvr:o:", long_options, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "hVr:o:", long_options, NULL)) != -1) {
switch (c) {
case 'h':
show_help(argv[0]);
return 0;
case 'v':
case 'V':
fprintf(stdout, "%s\n"
"Compiled with libpipewire %s\n"
"Linked with libpipewire %s\n",