int initialize_and_process_args(int argc, char *argv[]) { /* initialize option defaults */ _opt_default(); /* initialize options with env vars */ _opt_env(); /* initialize options with argv */ _opt_args(argc, argv); if (opt.verbose > 2) _opt_list(); return 1; }
/* * parse_command_line */ extern void parse_command_line( int argc, char* *argv ) { int opt_char; int option_index; static struct option long_options[] = { {"noheader", no_argument, 0, 'h'}, {"jobs", optional_argument, 0, 'j'}, {"long", no_argument, 0, 'l'}, {"cluster", required_argument, 0, 'M'}, {"clusters", required_argument, 0, 'M'}, {"norm", no_argument, 0, 'n'}, {"format", required_argument, 0, 'o'}, {"user", required_argument, 0, 'u'}, {"users", required_argument, 0, 'u'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, {"weights", no_argument, 0, 'w'}, {"help", no_argument, 0, OPT_LONG_HELP}, {"usage", no_argument, 0, OPT_LONG_USAGE}, {NULL, 0, 0, 0} }; /* get defaults from environment */ _opt_env(); while((opt_char = getopt_long(argc, argv, "hj::lM:no:u:vVw", long_options, &option_index)) != -1) { switch (opt_char) { case (int)'?': fprintf(stderr, "Try \"sprio --help\" " "for more information\n"); exit(1); case (int)'h': params.no_header = true; break; case (int) 'j': if (optarg) { params.jobs = xstrdup(optarg); params.job_list = _build_job_list(params.jobs); } params.job_flag = true; break; case (int) 'l': params.long_list = true; break; case (int) 'M': FREE_NULL_LIST(params.clusters); if (!(params.clusters = slurmdb_get_info_cluster(optarg))) { print_db_notok(optarg, 0); exit(1); } break; case (int) 'n': params.normalized = true; break; case (int) 'o': xfree(params.format); params.format = xstrdup(optarg); break; case (int) 'u': xfree(params.users); params.users = xstrdup(optarg); params.user_list = _build_user_list(params.users); break; case (int) 'v': params.verbose++; break; case (int) 'V': print_slurm_version (); exit(0); case (int) 'w': params.weights = true; break; case OPT_LONG_HELP: _help(); exit(0); case OPT_LONG_USAGE: _usage(); exit(0); } } if (optind < argc) { if (params.job_flag) { params.jobs = xstrdup(argv[optind++]); params.job_list = _build_job_list(params.jobs); } if (optind < argc) { error("Unrecognized option: %s",argv[optind]); _usage(); exit(1); } } if (params.verbose) _print_options(); if (params.clusters) { if (list_count(params.clusters) > 1) { fatal("Only one cluster can be used at a time with " "sprio"); } working_cluster_rec = list_peek(params.clusters); } }