diff options
author | Steve Holme <steve_holme@hotmail.com> | 2014-02-02 14:58:25 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2014-02-03 18:38:14 +0000 |
commit | c35d05aa62cbeed14629769293e3c30ec59fc728 (patch) | |
tree | 7b020b05b46d1d9deea087f395fb14f579032dea /src/tool_operate.c | |
parent | 8034b08e0e49b21ab8b186575d638dee8c7dfb17 (diff) |
tool_operate: Moved command line argument parsing into separate function
Diffstat (limited to 'src/tool_operate.c')
-rw-r--r-- | src/tool_operate.c | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c index 76ffcd0da..af9e1de02 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -199,9 +199,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) CURL *curl = NULL; char *httpgetfields = NULL; - bool stillflags; int res = 0; - int i; unsigned long li; bool orig_noprogress; @@ -251,44 +249,15 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) } } - /* Parse options */ - for(i = 1, stillflags = TRUE; i < argc; i++) { - char *orig_opt = argv[i]; - - if(stillflags && - ('-' == argv[i][0])) { - char *nextarg; - bool passarg; - char *flag = argv[i]; - - if(curlx_strequal("--", argv[i])) - /* this indicates the end of the flags and thus enables the - following (URL) argument to start with -. */ - stillflags = FALSE; - else { - nextarg = (i < (argc-1)) ? argv[i+1] : NULL; - - res = getparameter(flag, nextarg, &passarg, config); - if(!res && passarg) /* we're supposed to skip this */ - i++; - } - } - else { - bool used; - /* just add the URL please */ - res = getparameter((char *)"--url", argv[i], &used, config); - } + /* Parse the command line arguments */ + res = parse_args(config, argc, argv); + if(res) { + if(res != PARAM_HELP_REQUESTED) + res = CURLE_FAILED_INIT; + else + res = CURLE_OK; - if(res) { - int retval = CURLE_OK; - if(res != PARAM_HELP_REQUESTED) { - const char *reason = param2text(res); - helpf(config->errors, "option %s: %s\n", orig_opt, reason); - retval = CURLE_FAILED_INIT; - } - res = retval; - goto quit_curl; - } + goto quit_curl; } if(config->userpwd && !config->xoauth2_bearer) { |