1
/*
2
 * Hurl (https://hurl.dev)
3
 * Copyright (C) 2024 Orange
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *          http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 */
18
use clap::{value_parser, ArgAction};
19

            
20
24
pub fn compressed() -> clap::Arg {
21
24
    clap::Arg::new("compressed").long("compressed").num_args(0)
22
}
23

            
24
24
pub fn data() -> clap::Arg {
25
24
    clap::Arg::new("data")
26
24
        .long("data")
27
24
        .short('d')
28
24
        .value_name("data")
29
24
        .num_args(1)
30
}
31

            
32
24
pub fn headers() -> clap::Arg {
33
24
    clap::Arg::new("headers")
34
24
        .long("header")
35
24
        .short('H')
36
24
        .value_name("NAME:VALUE")
37
24
        .action(ArgAction::Append)
38
24
        .num_args(1)
39
}
40

            
41
24
pub fn insecure() -> clap::Arg {
42
24
    clap::Arg::new("insecure")
43
24
        .long("insecure")
44
24
        .short('k')
45
24
        .num_args(0)
46
}
47

            
48
24
pub fn location() -> clap::Arg {
49
24
    clap::Arg::new("location")
50
24
        .long("location")
51
24
        .short('L')
52
24
        .num_args(0)
53
}
54

            
55
24
pub fn max_redirects() -> clap::Arg {
56
24
    clap::Arg::new("max_redirects")
57
24
        .long("max-redirs")
58
24
        .value_name("NUM")
59
24
        .allow_hyphen_values(true)
60
24
        .value_parser(value_parser!(i32).range(-1..))
61
24
        .num_args(1)
62
}
63

            
64
24
pub fn method() -> clap::Arg {
65
24
    clap::Arg::new("method")
66
24
        .long("request")
67
24
        .short('X')
68
24
        .value_name("METHOD")
69
24
        .num_args(1)
70
}
71

            
72
24
pub fn retry() -> clap::Arg {
73
24
    clap::Arg::new("retry")
74
24
        .long("retry")
75
24
        .value_name("seconds")
76
24
        .value_parser(value_parser!(i32))
77
24
        .num_args(1)
78
}
79

            
80
24
pub fn url() -> clap::Arg {
81
24
    clap::Arg::new("url")
82
24
        .long("url")
83
24
        .value_name("url")
84
24
        .num_args(1)
85
}
86

            
87
24
pub fn url_param() -> clap::Arg {
88
24
    clap::Arg::new("url_param")
89
24
        .help("Sets the url to use")
90
24
        .required(false)
91
24
        .num_args(1)
92
}