From a76ddd39f06840073da70e3fbf2745bcb3eb1f3a Mon Sep 17 00:00:00 2001 From: aaravm Date: Mon, 15 Jul 2024 15:09:56 +0530 Subject: [PATCH] cargo.toml separating --- Cargo.toml | 42 +++++--------------- cli/Cargo.toml | 21 ++++++++++ cli/ga4gh-sdk-cli/Cargo.toml | 8 ---- cli/ga4gh-sdk-cli/src/main.rs | 75 ----------------------------------- cli/src/main.rs | 50 +++++++++++++++++++++++ lib/Cargo.toml | 36 +++++++++++++++++ 6 files changed, 118 insertions(+), 114 deletions(-) create mode 100644 cli/Cargo.toml delete mode 100644 cli/ga4gh-sdk-cli/Cargo.toml delete mode 100644 cli/ga4gh-sdk-cli/src/main.rs create mode 100644 cli/src/main.rs create mode 100644 lib/Cargo.toml diff --git a/Cargo.toml b/Cargo.toml index 34eeea7..e366e1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,33 +1,13 @@ -workspace = { members = ["cli/ga4gh-sdk-cli"] } -[package] -name = "ga4gh-sdk" +[workspace] +members = [ + "cli", + "lib" +] + +[workspace.package] version = "0.1.0" -authors = ["Aarav Mehta ", "Pavel Nikonorov", "ELIXIR Cloud & AAI "] +authors = ["Aarav Mehta (Google Summer of Code Participant)", "Pavel Nikonorov (Google Summer of Code Mentor; GENXT)", "ELIXIR Cloud & AAI (ELIXIR Europe)"] edition = "2021" -description = "Generic SDK and CLI for GA4GH API services" -license = "Apache-2.0" -repository = "https://github.com/elixir-cloud-aai/ga4gh-sdk.git" - -[dependencies] -tokio = { version = "1", features = ["full"] } -serde = "^1.0" -serde_derive = "^1.0" -serde_json = "^1.0" -url = "^2.2" -uuid = { version = "^1.0", features = ["serde", "v4"] } -log = "0.4" -env_logger = "0.9" -once_cell = "1.8.0" - -[dependencies.reqwest] -version = "^0.11" -features = ["json", "multipart"] - -[dev-dependencies] -mockito = "0.31" -mockall = "0.10.2" -cargo-nextest = "0.9.30" - -[lib] -name = "ga4gh_sdk" -path = "lib/src/lib.rs" +readme = "./README.md" +license-file = "LICENSE.txt" +repository = "https://github.com/elixir-cloud-aai/ga4gh-sdk.git" \ No newline at end of file diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 0000000..4548015 --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "cli" +description = """ +A cross-platform CLI tool written in Rust to use GA4GH-sdk +""" +repository = "https://github.com/elixir-cloud-aai/ga4gh-sdk/tree/main/cli" +version.workspace = true +authors.workspace = true +edition.workspace = true +readme.workspace = true +license-file.workspace = true + +[dependencies] +ga4gh-lib = { path = "../lib" } +clap = "3.0" +clap_complete = "3.0" +tokio = { version = "1", features = ["full"] } + +[[bin]] +name = "cli" +path = "src/main.rs" \ No newline at end of file diff --git a/cli/ga4gh-sdk-cli/Cargo.toml b/cli/ga4gh-sdk-cli/Cargo.toml deleted file mode 100644 index df5a655..0000000 --- a/cli/ga4gh-sdk-cli/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "ga4gh-sdk-cli" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/cli/ga4gh-sdk-cli/src/main.rs b/cli/ga4gh-sdk-cli/src/main.rs deleted file mode 100644 index a23ab48..0000000 --- a/cli/ga4gh-sdk-cli/src/main.rs +++ /dev/null @@ -1,75 +0,0 @@ -use clap::{arg, value_parser, Command}; -use clap_complete::{generate, Generator, Shell}; -use std::{error::Error, fs, io, path::Path}; - -// https://github.com/clap-rs/clap/blob/master/examples/git.rs -#[tokio::main] -async fn main() -> Result<(), Box> { - let mut cmd = Command::new("nanopub") - .bin_name("np") - .version(env!("CARGO_PKG_VERSION")) - .about("Sign, publish, and check Nanopublications.") - .subcommand_required(true) - .arg_required_else_help(true) - .subcommand( - Command::new("sign") - .about("Sign a Nanopub") - .arg(arg!( "The file to sign")) - .arg( - arg!(-k --key "The path to a private key used to sign. Found in ~/.nanopub by default") - .default_value("") - ) - .arg( - arg!(-p --profile "The path to a profile.yml file. Default: ~/.nanopub/profile.yml") - .default_value("") - ) - .arg_required_else_help(true), - ) - .subcommand( - Command::new("publish") - .about("Sign, publish, or check a Nanopublication (https://nanopub.net)") - .arg(arg!( "The file to publish")) - .arg( - arg!(-k --key "The path to a private key used to sign.") - .default_value("") - ) - .arg( - arg!(-p --profile "The path to a profile.yml file. Default: ~/.nanopub/profile.yml") - .default_value("") - ) - .arg( - arg!(-t --test "To publish to the test server instead of the Nanopublication network.") - ) - .arg_required_else_help(true), - ).subcommand( - Command::new("check") - .about("Check if a Nanopub is valid") - .arg(arg!( "The file to check")) - .arg_required_else_help(true), - ) - .subcommand( - Command::new("completions") - .about("Generates completion scripts for your shell") - .arg(arg!([SHELL] "The shell to generate scripts for") - .value_parser(value_parser!(Shell))) - ); - - let matches = cmd.clone().get_matches(); - - match matches.subcommand() { - Some(("sign", sub)) => { - - } - Some(("publish", sub)) => { - - } - Some(("check", sub)) => { - - } - Some(("completions", sub)) => { - - } - _ => {} - } - Ok(()) -} diff --git a/cli/src/main.rs b/cli/src/main.rs new file mode 100644 index 0000000..c256aac --- /dev/null +++ b/cli/src/main.rs @@ -0,0 +1,50 @@ +use clap::{arg, Command}; +use std::error::Error; +use crate::tes; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let mut cmd = Command::new("cli") + .bin_name("cli") + .version("1.0") + .about("CLI to manage tasks") + .subcommand_required(true) + .arg_required_else_help(true) + .subcommand( + Command::new("tes") + .about("TES subcommands") + .subcommand_required(true) + .arg_required_else_help(true) + .subcommand( + Command::new("create") + .about("Create a task") + .arg(arg!( "The task file to create")) + .arg(arg!(--url "The URL for the task").required(true)) + .arg_required_else_help(true), + ) + ); + + let matches = cmd.clone().get_matches(); + + match matches.subcommand() { + Some(("tes", sub)) => { + match sub.subcommand() { + Some(("create", sub)) => { + let task_file = sub.value_of("TASK_FILE").unwrap(); + let url = sub.value_of("url").unwrap(); + tes::create(task_file, url).await?; + } + _ => {} + } + } + _ => {} + } + Ok(()) +} + +// lib/src/tes/mod.rs +pub async fn create(task_file: &str, url: &str) -> Result<(), Box> { + // Your implementation here + println!("Creating task with file: {} and URL: {}", task_file, url); + Ok(()) +} diff --git a/lib/Cargo.toml b/lib/Cargo.toml new file mode 100644 index 0000000..401c108 --- /dev/null +++ b/lib/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "ga4gh-lib" +description = """ +Generic SDK and CLI for GA4GH API services +""" +repository = "https://github.com/elixir-cloud-aai/ga4gh-sdk/tree/main/lib" +version.workspace = true +authors.workspace = true +edition.workspace = true +readme.workspace = true +license-file.workspace = true +# rust-version = "1.74" + +[dependencies] +tokio = { version = "1", features = ["full"] } +serde = "^1.0" +serde_derive = "^1.0" +serde_json = "^1.0" +url = "^2.2" +uuid = { version = "^1.0", features = ["serde", "v4"] } +log = "0.4" +env_logger = "0.9" +once_cell = "1.8.0" + +[dependencies.reqwest] +version = "^0.11" +features = ["json", "multipart"] + +[dev-dependencies] +mockito = "0.31" +mockall = "0.10.2" +cargo-nextest = "0.9.30" + +[lib] +name = "ga4gh_sdk" +path = "lib/src/lib.rs"