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
27
pub fn compressed() -> clap::Arg {
21
27
    clap::Arg::new("compressed").long("compressed").num_args(0)
22
}
23

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

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

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

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

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

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

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

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

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