1
/*
2
 * Hurl (https://hurl.dev)
3
 * Copyright (C) 2025 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
33
pub fn compressed() -> clap::Arg {
21
33
    clap::Arg::new("compressed").long("compressed").num_args(0)
22
}
23

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

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

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

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

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

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

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

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

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

            
94
33
pub fn verbose() -> clap::Arg {
95
33
    clap::Arg::new("verbose")
96
33
        .long("verbose")
97
33
        .short('v')
98
33
        .num_args(0)
99
}