From 62d25c9f65c789e3ebdf81eaeac8bd53f8c9a075 Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Mon, 10 Feb 2025 16:40:23 +0100 Subject: [PATCH] glcli: Rename package In ordert to stick to the naming scheme that has established around greenlight crates which is `gl-` we change the name of the crate to be published to crates.io. When using the binary, the newly introduced hyphen might be a bit cumbersome so we keep the name of the binary `glcli`. Signed-off-by: Peter Neuroth --- Cargo.lock | 30 ++++++++++++++--------------- libs/gl-cli/Cargo.toml | 7 ++++++- libs/gl-cli/src/bin/glcli.rs | 14 ++++++++++++++ libs/gl-cli/src/{main.rs => lib.rs} | 28 +++++++++++++-------------- 4 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 libs/gl-cli/src/bin/glcli.rs rename libs/gl-cli/src/{main.rs => lib.rs} (89%) diff --git a/Cargo.lock b/Cargo.lock index 705ceeea4..ac0a114dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1306,6 +1306,21 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +[[package]] +name = "gl-cli" +version = "0.1.0" +dependencies = [ + "clap", + "dirs", + "env_logger 0.11.5", + "futures", + "gl-client", + "hex", + "thiserror 2.0.11", + "tokio 1.43.0", + "vls-core", +] + [[package]] name = "gl-client" version = "0.3.0" @@ -1444,21 +1459,6 @@ dependencies = [ "which 4.4.2", ] -[[package]] -name = "glcli" -version = "0.1.0" -dependencies = [ - "clap", - "dirs", - "env_logger 0.11.5", - "futures", - "gl-client", - "hex", - "thiserror 2.0.11", - "tokio 1.43.0", - "vls-core", -] - [[package]] name = "governor" version = "0.5.1" diff --git a/libs/gl-cli/Cargo.toml b/libs/gl-cli/Cargo.toml index 2dbbd5fa8..47f8446a6 100644 --- a/libs/gl-cli/Cargo.toml +++ b/libs/gl-cli/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "glcli" +name = "gl-cli" version = "0.1.0" edition = "2021" authors = ["Peter Neuroth "] @@ -12,6 +12,11 @@ categories = ["command-line-utlis", "cryptography::cryptocurrencies"] license = "MIT" reademe = "README.md" +[[bin]] +name = "glcli" +test = true +doc = true + [dependencies] clap = { version = "4.5", features = ["derive"] } dirs = "6.0" diff --git a/libs/gl-cli/src/bin/glcli.rs b/libs/gl-cli/src/bin/glcli.rs new file mode 100644 index 000000000..d224311c6 --- /dev/null +++ b/libs/gl-cli/src/bin/glcli.rs @@ -0,0 +1,14 @@ +use clap::Parser; +use gl_cli::{run, Cli}; + +#[tokio::main] +async fn main() { + let cli = Cli::parse(); + + match run(cli).await { + Ok(()) => (), + Err(e) => { + println!("{}", e); + } + } +} diff --git a/libs/gl-cli/src/main.rs b/libs/gl-cli/src/lib.rs similarity index 89% rename from libs/gl-cli/src/main.rs rename to libs/gl-cli/src/lib.rs index bc6501e5d..3bdb70d2c 100644 --- a/libs/gl-cli/src/main.rs +++ b/libs/gl-cli/src/lib.rs @@ -11,7 +11,7 @@ mod util; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] -struct Cli { +pub struct Cli { /// The directory containing the seed and the credentials #[arg(short, long, global = true, help_heading = "Global options")] data_dir: Option, @@ -25,7 +25,7 @@ struct Cli { } #[derive(Subcommand, Debug)] -enum Commands { +pub enum Commands { /// Interact with the scheduler that is the brain of most operations #[command(subcommand)] Scheduler(scheduler::Command), @@ -37,19 +37,19 @@ enum Commands { Node(node::Command), } -#[tokio::main] -async fn main() { - let cli = Cli::parse(); +//#[tokio::main] +//async fn main() { +// let cli = Cli::parse(); +// +// match run(cli).await { +// Ok(()) => (), +// Err(e) => { +// println!("{}", e); +// } +// } +//} - match run(cli).await { - Ok(()) => (), - Err(e) => { - println!("{}", e); - } - } -} - -async fn run(cli: Cli) -> Result<()> { +pub async fn run(cli: Cli) -> Result<()> { if cli.verbose { if std::env::var("RUST_LOG").is_err() { std::env::set_var("RUST_LOG", "debug")