feat: add clap-test-3
This commit is contained in:
@@ -10,7 +10,8 @@ Project or files:
|
||||
│ └── zeroizing-alloc-demo
|
||||
├── __args
|
||||
│ ├── argh-test
|
||||
│ └── clap-test
|
||||
│ ├── clap-test
|
||||
│ └── clap-test-2
|
||||
├── __bin
|
||||
│ ├── goblin
|
||||
│ └── object-demo
|
||||
@@ -310,6 +311,6 @@ Project or files:
|
||||
├── vec.rs
|
||||
└── while.rs
|
||||
|
||||
282 directories, 38 files
|
||||
283 directories, 38 files
|
||||
```
|
||||
|
||||
|
||||
261
__args/clap-test-2/Cargo.lock
generated
Normal file
261
__args/clap-test-2/Cargo.lock
generated
Normal file
@@ -0,0 +1,261 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
"clap_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap-test-2"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap-verbosity-flag",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap-verbosity-flag"
|
||||
version = "3.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eeab6a5cdfc795a05538422012f20a5496f050223c91be4e5420bfd13c641fb1"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.95"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.40"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
8
__args/clap-test-2/Cargo.toml
Normal file
8
__args/clap-test-2/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "clap-test-2"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.42", features = ["derive", "env"] }
|
||||
clap-verbosity-flag = "3"
|
||||
158
__args/clap-test-2/src/main.rs
Normal file
158
__args/clap-test-2/src/main.rs
Normal file
@@ -0,0 +1,158 @@
|
||||
use clap::Parser;
|
||||
|
||||
// https://github.com/fastn-stack/kulfi/blob/main/malai/src/main.rs
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
println!("{:?}", cli);
|
||||
}
|
||||
|
||||
#[derive(clap::Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Cli {
|
||||
#[command(flatten)]
|
||||
verbose: clap_verbosity_flag::Verbosity,
|
||||
|
||||
#[command(subcommand)]
|
||||
pub command: Option<Command>,
|
||||
|
||||
// adding these two because when we run `cargo tauri dev,` it automatically passes these
|
||||
// arguments. need to figure out why and how to disable that, till then this is a workaround
|
||||
#[arg(default_value = "true", long, hide = true)]
|
||||
no_default_features: bool,
|
||||
#[arg(default_value = "auto", long, hide = true)]
|
||||
color: String,
|
||||
}
|
||||
|
||||
#[derive(clap::Subcommand, Debug)]
|
||||
pub enum Command {
|
||||
// TODO: add this to the docs when we have ACL
|
||||
// By default it allows any peer to connect to the HTTP(s) service. You can pass --what-to-do
|
||||
// argument to specify a What To Do service that can be used to add access control."
|
||||
#[clap(about = "Expose HTTP Service on kulfi, connect using kulfi or browser")]
|
||||
Http {
|
||||
port: u16,
|
||||
#[arg(
|
||||
long,
|
||||
default_value = "127.0.0.1",
|
||||
help = "Host serving the http service."
|
||||
)]
|
||||
host: String,
|
||||
#[arg(
|
||||
long,
|
||||
default_value = "kulfi.site",
|
||||
help = "Use this for the HTTP bridge. To run an HTTP bridge, use `malai http-bridge`",
|
||||
env = "MALAI_HTTP_BRIDGE"
|
||||
)]
|
||||
bridge: String,
|
||||
#[arg(
|
||||
long,
|
||||
help = "Make the exposed service public. Anyone will be able to access."
|
||||
)]
|
||||
public: bool,
|
||||
// #[arg(
|
||||
// long,
|
||||
// default_value_t = false,
|
||||
// help = "Use this if the service is HTTPS"
|
||||
// )]
|
||||
// secure: bool,
|
||||
// #[arg(
|
||||
// long,
|
||||
// help = "The What To Do Service that can be used to add access control."
|
||||
// )]
|
||||
// this will be the id52 of the identity server that should be consulted
|
||||
// what_to_do: Option<String>,
|
||||
},
|
||||
#[clap(about = "Browse a kulfi site.")]
|
||||
Browse {
|
||||
#[arg(help = "The Kulfi URL to browse. Should look like kulfi://<id52>/<path>")]
|
||||
url: String,
|
||||
},
|
||||
#[clap(about = "Expose TCP Service on kulfi.")]
|
||||
Tcp {
|
||||
port: u16,
|
||||
#[arg(
|
||||
long,
|
||||
default_value = "127.0.0.1",
|
||||
help = "Host serving the TCP service."
|
||||
)]
|
||||
host: String,
|
||||
#[arg(
|
||||
long,
|
||||
help = "Make the exposed service public. Anyone will be able to access."
|
||||
)]
|
||||
public: bool,
|
||||
},
|
||||
#[clap(
|
||||
about = "Run an http server that forwards requests to the given id52 taken from the HOST header"
|
||||
)]
|
||||
HttpBridge {
|
||||
#[arg(
|
||||
long,
|
||||
short('t'),
|
||||
help = "The id52 to which this bridge will forward incoming HTTP request. By default it forwards to every id52."
|
||||
)]
|
||||
proxy_target: Option<String>,
|
||||
#[arg(
|
||||
long,
|
||||
short('p'),
|
||||
help = "The port on which this bridge will listen for incoming HTTP requests. If you pass 0, it will bind to a random port.",
|
||||
default_value = "0"
|
||||
)]
|
||||
port: u16,
|
||||
},
|
||||
#[clap(about = "Run a TCP server that forwards incoming requests to the given id52.")]
|
||||
TcpBridge {
|
||||
#[arg(help = "The id52 to which this bridge will forward incoming TCP request.")]
|
||||
proxy_target: String,
|
||||
#[arg(
|
||||
help = "The port on which this bridge will listen for incoming TCP requests. If you pass 0, it will bind to a random port.",
|
||||
default_value = "0"
|
||||
)]
|
||||
port: u16,
|
||||
},
|
||||
#[clap(about = "Expose a folder to kulfi network")]
|
||||
Folder {
|
||||
#[arg(help = "The folder to expose.")]
|
||||
path: String,
|
||||
#[arg(
|
||||
long,
|
||||
default_value = "kulfi.site",
|
||||
help = "Use this for the HTTP bridge. To run an HTTP bridge, use `malai http-bridge`",
|
||||
env = "MALAI_HTTP_BRIDGE"
|
||||
)]
|
||||
bridge: String,
|
||||
#[arg(long, help = "Make the folder public. Anyone will be able to access.")]
|
||||
public: bool,
|
||||
},
|
||||
#[clap(about = "Run all the services")]
|
||||
Run {
|
||||
#[arg(long, help = "Malai Home", env = "MALAI_HOME")]
|
||||
home: Option<String>,
|
||||
},
|
||||
#[clap(about = "Run an iroh remote server that handles requests from http-proxy.")]
|
||||
HttpProxyRemote {
|
||||
#[arg(long, help = "Make the proxy public. Anyone will be able to access.")]
|
||||
public: bool,
|
||||
},
|
||||
#[clap(about = "Run a http proxy server that forwards incoming requests to http-proxy-remote.")]
|
||||
HttpProxy {
|
||||
#[arg(help = "The id52 of remote to which this http proxy will forward request to.")]
|
||||
remote: String,
|
||||
#[arg(
|
||||
help = "The port on which this proxy will listen for incoming TCP requests. If you pass 0, it will bind to a random port.",
|
||||
default_value = "0"
|
||||
)]
|
||||
port: u16,
|
||||
},
|
||||
#[clap(about = "Generate a new identity.")]
|
||||
Keygen {
|
||||
#[arg(
|
||||
long,
|
||||
short,
|
||||
num_args=0..=1,
|
||||
//default_missing_value=kulfi_utils::SECRET_KEY_FILE,
|
||||
help = "The file where the private key of the identity will be stored. If not provided, the private key will be printed to stdout."
|
||||
)]
|
||||
file: Option<String>,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user