~ubuntu-branches/ubuntu/wily/davix/wily

« back to all changes in this revision

Viewing changes to src/tools/davix_tool_params.cpp

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2015-07-31 13:17:55 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20150731131755-mizprbmn7ogv33te
Tags: 0.4.1-1
* Update to version 0.4.1
* Implement Multi-Arch support

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#define CONN_TIMEOUT        1011
49
49
#define TIMEOUT_OPS         1012
50
50
#define RETRY_OPT           1013
 
51
#define S3_LISTING_MODE     1014
 
52
#define S3_MAX_KEYS         1015
 
53
#define RETRY_DELAY_OPT     1016
51
54
 
52
55
// LONG OPTS
53
56
 
61
64
{"redirection", required_argument, 0, REDIRECTION_OPT }, \
62
65
{"conn-timeout", required_argument, 0, CONN_TIMEOUT }, \
63
66
{"retry", required_argument, 0, RETRY_OPT }, \
 
67
{"retry-delay", required_argument, 0, RETRY_DELAY_OPT }, \
64
68
{"timeout", required_argument, 0, TIMEOUT_OPS }, \
65
69
{"trace", required_argument, 0, TRACE_OPTIONS }, \
66
 
{"verbose", no_argument, 0,  0 }, \
67
70
{"version", no_argument, 0, 'V'}
68
71
 
69
72
#define SECURITY_LONG_OPTIONS \
82
85
{"verbose", no_argument, 0,  0 }
83
86
 
84
87
#define LISTING_LONG_OPTIONS \
 
88
{"s3-listing", required_argument, 0,  S3_LISTING_MODE }, \
 
89
{"s3-maxkeys", required_argument, 0,  S3_MAX_KEYS }, \
85
90
{"long-list", no_argument, 0,  'l' }
86
91
 
87
92
OptParams::OptParams() :
88
93
    params(),
89
94
    vec_arg(),
90
 
    verbose(false),
91
95
    debug(false),
92
96
    req_type(),
93
97
    help_msg(),
188
192
                p.debug = true;
189
193
                // max log level
190
194
                setLogLevel(DAVIX_LOG_TRACE);
191
 
                setLogScope(DAVIX_LOG_SCOPE_ALL | DAVIX_LOG_SCOPE_NEON | DAVIX_LOG_BODY | DAVIX_LOG_XML);
 
195
                setLogScope(DAVIX_LOG_SCOPE_ALL ^ DAVIX_LOG_XML);
192
196
                break;
193
197
            case 'E':
194
198
                 p.cred_path = SanitiseTildedPath(optarg);
200
204
                if( set_header_field(optarg, p, err) <0)
201
205
                    return -1;
202
206
                break;
 
207
            case S3_LISTING_MODE:
 
208
                {
 
209
                    if(std::string(optarg).compare("flat")==0)
 
210
                        p.params.setS3ListingMode(S3ListingMode::Flat); 
 
211
                    else if(std::string(optarg).compare("hierarchical")==0)
 
212
                        p.params.setS3ListingMode(S3ListingMode::Hierarchical);
 
213
                    else if(std::string(optarg).compare("semi")==0)
 
214
                        p.params.setS3ListingMode(S3ListingMode::SemiHierarchical);
 
215
                    break;
 
216
                }
 
217
            case S3_MAX_KEYS:
 
218
                p.params.setS3MaxKey(atoi(optarg));
 
219
                break;
203
220
            case CAPATH_OPT:
204
221
                p.params.addCertificateAuthorityPath(optarg);
205
222
                break;
218
235
            case RETRY_OPT:
219
236
                p.params.setOperationRetry( parse_int(optarg, argv));
220
237
                break;
 
238
            case RETRY_DELAY_OPT:
 
239
                p.params.setOperationRetryDelay( parse_int(optarg, argv));
 
240
                break;
221
241
            case S3_ACCESS_KEY:
222
242
                p.aws_auth.second = optarg;
223
243
                break;
238
258
                return 1;
239
259
            case TRACE_OPTIONS:
240
260
                {
 
261
                    p.debug = true;
241
262
                    setLogScope(0);
242
263
                    setLogScope(std::string(optarg));
243
264
                    setLogLevel(DAVIX_LOG_TRACE);
266
287
                break;
267
288
             }
268
289
            case '?':
269
 
            printf(p.help_msg.c_str(), argv[0]);
270
 
                return -1;
 
290
                std::cout <<  p.help_msg;
 
291
                exit(1);
271
292
          break;
272
293
            default:
273
294
                option_abort(argv);
306
327
 
307
328
 
308
329
int parse_davix_ls_options(int argc, char** argv, OptParams & p, DavixError** err){
309
 
    const std::string arg_tool_main= "P:x:H:E:vkVl";
 
330
    const std::string arg_tool_main= "P:x:H:E:vkVlf";
310
331
    const struct option long_options[] = {
311
332
        COMMON_LONG_OPTIONS,
312
333
        SECURITY_LONG_OPTIONS,
372
393
}
373
394
 
374
395
 
375
 
const std::string  & get_common_options(){
376
 
    static const std::string s(
377
 
            "  Common Options:\n"
 
396
std::string get_common_options(){
 
397
           return  "  Common Options:\n"
378
398
            "\t--conn-timeout TIME:      Connection timeout in seconds. default: 30\n"
 
399
            "\t--retry NUMBER:           Number of retry attempt in case of an operation failure. default: 10\n"
 
400
            "\t--retry-delay TIME:       Number of seconds to wait between retry attempts. default: 0\n"
379
401
            "\t--debug:                  Debug mode\n"
380
402
            "\t--header, -H:             Add a header field to the request\n"
381
403
            "\t--help, -h:               Display this help message\n"
384
406
            "\t--proxy, -x URL:          SOCKS5 proxy server URL. (Ex: socks5://login:pass@socks.example.org)\n"
385
407
            "\t--redirection OPT:        Transparent redirection support. value=yes|no. default=yes)\n"
386
408
            "\t--timeout TIME:           Global timeout for the operation in seconds. default: infinite\n"
387
 
            "\t--trace:                  Specify one or more scpoes to trace. (Ex: --trace log level(optional),header,file)\n"
388
 
            "\t--verbose:                Verbose mode\n"
 
409
            "\t--trace:                  Specify one or more scopes to trace. (Ex: --trace log level(optional),header,file)\n"
389
410
            "\t--version, -V:            Display version\n"
390
411
            "  Security Options:\n"
391
412
            "\t--capath CA_PATH:         Add an additional certificate authority directory\n"
396
417
            "\t--userpass:               User password for login/password authentication\n"
397
418
            "\t--s3secretkey SEC_KEY:    S3 authentication: secret key\n"
398
419
            "\t--s3accesskey ACC_KEY:    S3 authentication: access key\n"
399
 
            );
400
 
    return s;
401
 
}
402
 
 
403
 
 
404
 
 
405
 
const std::string  & get_base_description_options(){
406
 
    static const std::string s("Usage: {} [OPTIONS ...] <url>\n"
407
 
            );
408
 
    return s;
409
 
}
410
 
 
411
 
 
412
 
const std::string  & get_put_description_options(){
413
 
    static const std::string s("Usage: {} [OPTIONS ...] <local_file> <remote_file_url> \n"
414
 
            );
415
 
    return s;
416
 
}
417
 
 
418
 
 
419
 
const std::string  & get_copy_description_options(){
420
 
    static const std::string s("Usage: {} [OPTIONS ...] <src_url> <dst_url>\n"
421
 
            );
422
 
    return s;
 
420
            ;
 
421
}
 
422
 
 
423
 
 
424
 
 
425
std::string  get_base_description_options(){
 
426
    return "[OPTIONS ...] <url>\n"
 
427
            ;
 
428
}
 
429
 
 
430
std::string  get_get_description_options(){
 
431
    return "[OPTIONS ...] <url> [local_file]\n"
 
432
            ;
 
433
}
 
434
 
 
435
 
 
436
 
 
437
std::string get_put_description_options(){
 
438
    return "[OPTIONS ...] <local_file> <remote_file_url> \n"
 
439
            ;
 
440
}
 
441
 
 
442
 
 
443
std::string get_copy_description_options(){
 
444
    return "[OPTIONS ...] <src_url> <dst_url>\n"
 
445
            ;
423
446
}
424
447
 
425
448
}