1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use std::path::PathBuf;
use clap::Subcommand;
use nestify::nest;
nest! {
#[derive(clap::Args, Debug, Clone)]
pub struct ImportCommand {
/// The type of file to import
#[command(subcommand)]
pub import_type: #[derive(Subcommand, Debug, Clone)] pub enum ImportType {
/// Import a Postman v2.1.0 file
Postman(PostmanImport),
/// Import a curl file
Curl(CurlImport),
/// Import an Open Api file
#[clap(alias = "openapi")]
OpenApi(OpenApiImport)
}
}
}
#[derive(clap::Args, Debug, Clone)]
pub struct PostmanImport {
/// Path to the file to import
#[clap(value_hint = clap::ValueHint::FilePath)]
pub import_path: PathBuf,
/// Max depth at which import should stop creating nested collections and only get the deeper requests
#[arg(long)]
pub max_depth: Option<u16>,
}
#[derive(clap::Args, Debug, Clone)]
pub struct CurlImport {
/// Path to the file/folder to import
#[clap(value_hint = clap::ValueHint::AnyPath)]
pub import_path: PathBuf,
/// Collection name to save the request to
pub collection_name: String,
/// Request name (will use the file name if none is provided)
pub request_name: Option<String>,
/// Search for deeper files
#[arg(short, long, conflicts_with = "request_name")]
pub recursive: bool,
/// Max depth at which import should stop creating nested collections and only get the deeper requests
#[arg(long, requires = "recursive", conflicts_with = "request_name")]
pub max_depth: Option<u16>,
}
#[derive(clap::Args, Debug, Clone)]
pub struct OpenApiImport {
/// Path to the file to import
#[clap(value_hint = clap::ValueHint::FilePath)]
pub import_path: PathBuf,
/// Max depth at which import should stop creating nested collections and only get the deeper requests
#[arg(long)]
pub max_depth: Option<u16>,
}