This commit is contained in:
FroVolod
2022-02-24 05:27:13 +02:00
parent 6e3f514728
commit defa1acf74
7 changed files with 44 additions and 2 deletions

View File

@@ -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 }

View File

@@ -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
View File

@@ -0,0 +1,2 @@
pub mod snake_case_to_camel_case;
pub mod to_kebab_case;

View 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("")
}

View 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("_", "-")
}

View File

@@ -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;
}