From f84817754d34dd75301b5257a2119a54085c7a4d Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Thu, 2 Oct 2003 20:47:35 +0000 Subject: [PATCH] Modify popt use to conform with spec (and not fail under RedHat 9). --- src/scancel/opt.c | 8 ++++++-- src/sinfo/opts.c | 38 ++++++++++++++++++++++++++++---------- src/sinfo/sinfo.h | 1 - src/squeue/opts.c | 25 ++++++++++++++++--------- 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/src/scancel/opt.c b/src/scancel/opt.c index e287057ab88..33d25ecbdf3 100644 --- a/src/scancel/opt.c +++ b/src/scancel/opt.c @@ -76,7 +76,7 @@ #endif struct poptOption options[] = { - {"interactive", 'i', POPT_ARG_NONE, &opt.interactive, OPT_INTERACTIVE, + {"interactive", 'i', POPT_ARG_NONE, NULL, OPT_INTERACTIVE, "confirm each job cancelation", }, {"name", 'n', POPT_ARG_STRING, NULL, OPT_NAME, "name of job", "name"}, @@ -88,7 +88,7 @@ struct poptOption options[] = { "name of job's state", "PENDING | RUNNING"}, {"user", 'u', POPT_ARG_STRING, NULL, OPT_USER, "name of job's owner", "name"}, - {"verbose", 'v', 0, 0, OPT_VERBOSE, + {"verbose", 'v', POPT_ARG_NONE, NULL, OPT_VERBOSE, "verbose operation (multiple -v's increase verbosity)", }, {"version", 'V', POPT_ARG_NONE, NULL, OPT_VERSION, "report the current version", }, @@ -338,6 +338,10 @@ static void opt_args(int ac, char **av) arg = poptGetOptArg(optctx); switch (rc) { + case OPT_INTERACTIVE: + opt.interactive = true; + break; + case OPT_NAME: opt.job_name = xstrdup(arg); break; diff --git a/src/sinfo/opts.c b/src/sinfo/opts.c index ce5e074f5bb..a2ad1d25570 100644 --- a/src/sinfo/opts.c +++ b/src/sinfo/opts.c @@ -79,7 +79,7 @@ int parse_command_line(int argc, char *argv[]) /* Declare the Options */ static const struct poptOption options[] = { - {"exact", 'e', POPT_ARG_NONE, ¶ms.exact_match, OPT_EXACT, + {"exact", 'e', POPT_ARG_NONE, NULL, OPT_EXACT, "group nodes only on exact match of configuration", NULL}, {"iterate", 'i', POPT_ARG_INT, ¶ms.iterate, @@ -94,19 +94,19 @@ int parse_command_line(int argc, char *argv[]) "PARTITION"}, {"nodes", 'n', POPT_ARG_STRING, ¶ms.nodes, OPT_NODES, "report on specific node(s)", "NODES"}, - {"Node", 'N', POPT_ARG_NONE, ¶ms.node_flag, OPT_NODE, + {"Node", 'N', POPT_ARG_NONE, NULL, OPT_NODE, "Node-centric format", NULL}, - {"long", 'l', POPT_ARG_NONE, ¶ms.long_output, - OPT_LONG, "long output - displays more information", + {"long", 'l', POPT_ARG_NONE, NULL, OPT_LONG, + "long output - displays more information", NULL}, {"sort", 'S', POPT_ARG_STRING, ¶ms.sort, OPT_SORT, "comma seperated list of fields to sort on", "fields"}, - {"summarize", 's', POPT_ARG_NONE, ¶ms.summarize, - OPT_SHORT,"report state summary only", NULL}, - {"verbose", 'v', POPT_ARG_NONE, ¶ms.verbose, - OPT_VERBOSE, "verbosity level", "level"}, - {"noheader", 'h', POPT_ARG_NONE, ¶ms.no_header, - OPT_NO_HEAD, "no headers on output", NULL}, + {"summarize", 's', POPT_ARG_NONE, NULL, OPT_SHORT, + "report state summary only", NULL}, + {"verbose", 'v', POPT_ARG_NONE, NULL, OPT_VERBOSE, + "verbosity level", "level"}, + {"noheader", 'h', POPT_ARG_NONE, NULL, OPT_NO_HEAD, + "no headers on output", NULL}, {"format", 'o', POPT_ARG_STRING, ¶ms.format, OPT_FORMAT, "format specification", "format"}, {"version", 'V', POPT_ARG_NONE, 0, OPT_VERSION, @@ -124,9 +124,27 @@ int parse_command_line(int argc, char *argv[]) while ((curr_opt = poptGetNextOpt(context)) > 0) { switch ( curr_opt ) { + case OPT_EXACT: + params.exact_match = true; + break; case OPT_NODE_STATE: params.state_list = _build_state_list( params.states ); break; + case OPT_NODE: + params.node_flag = true; + break; + case OPT_LONG: + params.long_output = true; + break; + case OPT_SHORT: + params.summarize = true; + break; + case OPT_VERBOSE: + params.verbose++; + break; + case OPT_NO_HEAD: + params.no_header = true; + break; case OPT_VERSION: _print_version(); exit(0); diff --git a/src/sinfo/sinfo.h b/src/sinfo/sinfo.h index 4a3d9501b7c..8e7f33842d1 100644 --- a/src/sinfo/sinfo.h +++ b/src/sinfo/sinfo.h @@ -102,7 +102,6 @@ struct sinfo_parameters { bool exact_match; bool filtering; bool long_output; - bool line_wrap; bool no_header; bool node_field_flag; bool node_flag; diff --git a/src/squeue/opts.c b/src/squeue/opts.c index 32c2d2fc9f8..6ce30ed8c85 100644 --- a/src/squeue/opts.c +++ b/src/squeue/opts.c @@ -86,17 +86,16 @@ parse_command_line( int argc, char* argv[] ) {"iterate", 'i', POPT_ARG_INT, ¶ms.iterate, OPT_ITERATE, "specify an interation period", "seconds"}, - {"noheader", 'h', POPT_ARG_NONE, ¶ms.no_header, - OPT_NO_HEAD, "no headers on output", NULL}, - {"jobs", 'j', POPT_ARG_NONE, ¶ms.job_flag, OPT_JOBS_NONE, + {"noheader", 'h', POPT_ARG_NONE, NULL, OPT_NO_HEAD, + "no headers on output", NULL}, + {"jobs", 'j', POPT_ARG_NONE, NULL, OPT_JOBS_NONE, "comma separated list of jobs to view, default is all", "job_id"}, - {"steps", 's', POPT_ARG_NONE, ¶ms.step_flag, - OPT_STEPS_NONE, + {"steps", 's', POPT_ARG_NONE, NULL, OPT_STEPS_NONE, "comma separated list of job steps to view, " "default is all", "job_step"}, - {"long", 'l', POPT_ARG_NONE, ¶ms.long_list, OPT_LONG, + {"long", 'l', POPT_ARG_NONE, NULL, OPT_LONG, "long report", NULL}, {"sort", 'S', POPT_ARG_STRING, ¶ms.sort, OPT_SORT, "comma seperated list of fields to sort on", "fields"}, @@ -113,9 +112,9 @@ parse_command_line( int argc, char* argv[] ) "format specification", "format"}, {"user", 'u', POPT_ARG_STRING, ¶ms.users, OPT_USERS, "comma separated list of users to view", "user_name"}, - {"verbose", 'v', POPT_ARG_NONE, ¶ms.verbose, OPT_VERBOSE, + {"verbose", 'v', POPT_ARG_NONE, NULL, OPT_VERBOSE, "verbosity level", NULL}, - {"version", 'V', POPT_ARG_NONE, 0, OPT_VERSION, + {"version", 'V', POPT_ARG_NONE, NULL, OPT_VERSION, "output version information and exit", NULL}, POPT_AUTOHELP {NULL, '\0', 0, NULL, 0, NULL, NULL} /* end the list */ @@ -137,16 +136,24 @@ parse_command_line( int argc, char* argv[] ) switch ( curr_opt ) { + case OPT_NO_HEAD: + params.no_header = true; + break; case OPT_JOBS_NONE: if ( (opt_arg = poptGetArg(context)) != NULL ) params.jobs = (char*)opt_arg; params.job_list = _build_job_list(params.jobs); + params.job_flag = true; break; case OPT_STEPS_NONE: if ( (opt_arg = poptGetArg( context )) != NULL ) params.steps = (char*)opt_arg; params.step_list = _build_step_list( params.steps ); + params.step_flag = true; break; + case OPT_LONG: + params.long_list = true; + break; case OPT_STATES: params.state_list = _build_state_list( params.states ); break; @@ -158,7 +165,7 @@ parse_command_line( int argc, char* argv[] ) params.user_list = _build_user_list( params.users ); break; case OPT_VERBOSE: - params.verbose = true; + params.verbose++; break; case OPT_VERSION: _print_version(); -- GitLab