Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ openssl = { version = "0.10.75", optional = true }
reqwest = { version = "0.12.28", default-features = false, features = [
"json",
"multipart",
"stream",
] }
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
snafu = { version = "0.8.5" }
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7", features = ["codec"] }
walkdir = "2"
tabled = "0.20.0"
chrono = "0.4.43"
futures = { version = "0.3" }
regex = { version = "1.12.3" }
iso8601-timestamp = { version = "0.2.17" }
Expand All @@ -54,13 +59,14 @@ self_update = { version = "0.43.1", features = [
"archive-zip",
"compression-flate2",
] }
md5 = "0.8.0"

[features]
default = ["reqwest/default-tls"] # link against system library
rustls = [
"reqwest/rustls-tls",
"openidconnect/rustls-tls",
"self_update/rustls"
"self_update/rustls",
] # include rustls, ssl library written in rust
vendored-openssl = ["openssl/vendored"] # include compiled openssl library
vendored-zlib = [
Expand Down
2 changes: 2 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub async fn execute_cmd(opts: MainOpts) -> Result<(), CmdError> {

#[cfg(feature = "user-doc")]
SubCommand::UserDoc(input) => input.exec(ctx).await?,

SubCommand::Dataset(input) => input.exec(ctx).await?,
};
Ok(())
}
Expand Down
10 changes: 10 additions & 0 deletions src/cli/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod dataset;
pub mod login;
pub mod project;
pub mod update;
Expand Down Expand Up @@ -109,6 +110,9 @@ pub enum CmdError {
#[cfg(feature = "user-doc")]
#[snafu(display("UserDoc - {}", source))]
UserDoc { source: userdoc::Error },

#[snafu(display("Dataset - {}", source))]
Dataset { source: dataset::Error },
}

impl From<version::Error> for CmdError {
Expand Down Expand Up @@ -140,3 +144,9 @@ impl From<login::Error> for CmdError {
CmdError::Login { source }
}
}

impl From<dataset::Error> for CmdError {
fn from(source: dataset::Error) -> Self {
CmdError::Dataset { source }
}
}
80 changes: 80 additions & 0 deletions src/cli/cmd/dataset.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
pub mod deposit;
pub mod zenodo;
mod zenodo_api;

use super::Context as ParentContext;
use clap::{Parser, ValueEnum};
use snafu::{ResultExt, Snafu};

#[derive(Debug, Clone, ValueEnum)]
pub enum Provider {
Zenodo,
}

#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("Error with deposit: {}", source))]
Deposit { source: deposit::Error },
}

/// Sub command for managing datasets
#[derive(Parser, Debug)]
pub struct Input {
#[command(subcommand)]
pub subcmd: DatasetCommand,
}

#[derive(Parser, Debug)]
pub enum DatasetCommand {
Deposit {
#[arg(long, default_value = "zenodo")]
provider: Provider,
#[command(subcommand)]
cmd: DepositCommand,
},
}

#[derive(Parser, Debug)]
pub enum DepositCommand {
#[command(name = "cp")]
CopyFiles(deposit::CopyInput),
#[command(name = "ls")]
ListDeposits(deposit::ListInput),
#[command(name = "lsf")]
ListFiles(deposit::ListFiles),
}

pub struct Context {
pub parent: ParentContext,
pub provider: Provider,
}

impl Context {
pub fn new(ctx: ParentContext, provider: Provider) -> Context {
Context {
parent: ctx,
provider,
}
}
}

impl Input {
pub async fn exec(&self, ctx: ParentContext) -> Result<(), Error> {
match &self.subcmd {
DatasetCommand::Deposit { provider, cmd } => match cmd {
DepositCommand::CopyFiles(input) => input
.exec(Context::new(ctx, provider.clone()))
.await
.context(DepositSnafu),
DepositCommand::ListDeposits(input) => input
.exec(Context::new(ctx, provider.clone()))
.await
.context(DepositSnafu),
DepositCommand::ListFiles(input) => input
.exec(Context::new(ctx, provider.clone()))
.await
.context(DepositSnafu),
},
}
}
}
Loading
Loading