mirror of
https://github.com/Drop-OSS/interactive-clap.git
synced 2026-01-30 20:55:25 +01:00
qweqwe
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"interactive_clap_derive",
|
||||
]
|
||||
|
||||
[package]
|
||||
name = "interactive_clap"
|
||||
version = "0.1.0"
|
||||
@@ -6,7 +11,7 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
interactive_clap_derive = { path = "./interactive_clap_derive" }
|
||||
interactive_clap_derive = { path = "interactive_clap_derive" }
|
||||
|
||||
near-ledger = { version = "0.1.1", optional = true }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// ./simple_struct 30 QWE QWERTY => args: Ok(Args { age: 30, first_name: "QWE", second_name: "QWERTY" })
|
||||
// To learn more about the parameters, use "help" flag: ./simple_struct --help
|
||||
|
||||
#[derive(Debug, interactive_clap_derive::InteractiveClap)]
|
||||
#[derive(Debug, interactive_clap::InteractiveClap)]
|
||||
struct Args {
|
||||
age: u64,
|
||||
first_name: String,
|
||||
|
||||
2
src/helpers/mod.rs
Normal file
2
src/helpers/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod snake_case_to_camel_case;
|
||||
pub mod to_kebab_case;
|
||||
8
src/helpers/snake_case_to_camel_case.rs
Normal file
8
src/helpers/snake_case_to_camel_case.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
pub fn snake_case_to_camel_case(s: String) -> String {
|
||||
let s_vec: Vec<String> = s
|
||||
.to_lowercase()
|
||||
.split("_")
|
||||
.map(|s| s.replacen(&s[..1], &s[..1].to_ascii_uppercase(), 1))
|
||||
.collect();
|
||||
s_vec.join("")
|
||||
}
|
||||
10
src/helpers/to_kebab_case.rs
Normal file
10
src/helpers/to_kebab_case.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
pub fn to_kebab_case(s: String) -> String {
|
||||
let mut snake = String::new();
|
||||
for (i, ch) in s.char_indices() {
|
||||
if i > 0 && ch.is_uppercase() {
|
||||
snake.push('-');
|
||||
}
|
||||
snake.push(ch.to_ascii_lowercase());
|
||||
}
|
||||
snake.as_str().replace("_", "-")
|
||||
}
|
||||
17
src/lib.rs
17
src/lib.rs
@@ -1,3 +1,20 @@
|
||||
//! The Interactive-clap library is an add-on for the Command Line Argument
|
||||
//! Parser (https://crates.io/crates/clap). Interactive-clap allows you to parse
|
||||
//! command line options. The peculiarity of this macro is that in the absence
|
||||
//! of command line parameters, the interactive mode of entering these data by
|
||||
//! the user is activated.
|
||||
|
||||
|
||||
pub use interactive_clap_derive::{InteractiveClap, ToCliArgs};
|
||||
|
||||
// pub trait InteractiveClap {
|
||||
// fn interactive_clap();
|
||||
// }
|
||||
|
||||
// pub trait ToCliArgs {
|
||||
// fn to_cli_args();
|
||||
// }
|
||||
|
||||
pub trait ToCli {
|
||||
type CliVariant;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user