-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathcli.rs
52 lines (48 loc) · 1.48 KB
/
cli.rs
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
#[derive(Clone, Debug)]
pub enum Remote {
Http(String),
Ssh(String),
}
fn parse_remote(s: &str) -> Result<Remote, &'static str> {
match s {
s if s.starts_with("http://") || s.starts_with("https://") => {
Ok(Remote::Http(s.to_string()))
}
s if s.starts_with("ssh://") => Ok(Remote::Ssh(s.to_string())),
_ => return Err("unsupported scheme"),
}
}
#[derive(clap::Parser, Debug)]
#[command(name = "josh-proxy")]
pub struct Args {
#[arg(long, required = true, value_parser = parse_remote)]
pub remote: Vec<Remote>,
#[arg(long, required = true)]
pub local: Option<String>,
#[arg(name = "poll", long)]
pub poll_user: Option<String>,
#[arg(long, help = "Run git gc during maintenance")]
pub gc: bool,
#[arg(long)]
pub require_auth: bool,
#[arg(long)]
pub no_background: bool,
#[arg(
short,
help = "DEPRECATED - no effect! Number of concurrent upstream git fetch/push operations"
)]
_n: Option<String>,
#[arg(long, default_value = "8000")]
pub port: u16,
#[arg(
short,
default_value = "0",
help = "Duration between forced cache refresh"
)]
#[arg(long, short)]
pub cache_duration: u64,
#[arg(long, help = "Proxy static resource requests to a different URL")]
pub static_resource_proxy_target: Option<String>,
#[arg(long, help = "Filter to be prefixed to all queries of this instance")]
pub filter_prefix: Option<String>,
}