Skip to content
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions tvc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ inquire = { workspace = true }
p256 = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requires dep reviewer but thiserror is v commonly used, so I don't expect any issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's already a dep in the workspace so I'm not actually adding anything new, just exposing it to tvc.

toml = { workspace = true }
tokio = { workspace = true, features = ["fs"] }
zeroize = { workspace = true }
Expand Down
46 changes: 37 additions & 9 deletions tvc/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! CLI parsing and dispatch.

use crate::commands;
use clap::{Parser, Subcommand};
use clap::{ArgAction, Parser, Subcommand, builder::BoolishValueParser};
use tracing::debug;

const LONG_ABOUT: &str = "\
Expand All @@ -26,12 +26,26 @@ Authentication:
Local: run `tvc login` once; commands then read ~/.config/turnkey/.
CI: set TVC_ORG_ID, TVC_API_KEY_PUBLIC, and TVC_API_KEY_PRIVATE
to authenticate without files. Env vars take precedence over local
config files. Setting some but not all three required vars will error.";
config files. Setting some but not all three required vars will error.

Interactive behavior:
By default, commands may prompt when stdin is a TTY. Use --non-interactive
or set TVC_NON_INTERACTIVE=true to disable prompts and fail fast instead.";

/// CLI command parsing and dispatch.
#[derive(Debug, Parser)]
#[command(about = "CLI for building with Turnkey Verifiable Cloud", long_about = LONG_ABOUT)]
pub struct Cli {
/// Disable interactive prompts and fail fast when required values are missing.
#[arg(
long,
global = true,
env = "TVC_NON_INTERACTIVE",
action = ArgAction::SetTrue,
value_parser = BoolishValueParser::new()
)]
non_interactive: bool,

#[command(subcommand)]
command: Commands,
}
Expand All @@ -40,27 +54,41 @@ impl Cli {
/// Run the CLI.
pub async fn run() -> anyhow::Result<()> {
let args = Cli::parse();
debug!(command = args.command.name(), "dispatching");
debug!(
command = args.command.name(),
non_interactive = args.non_interactive,
"dispatching"
);

let non_interactive = args.non_interactive;

match args.command {
Commands::Deploy { command } => match command {
DeployCommands::Approve(args) => commands::deploy::approve::run(args).await,
DeployCommands::Approve(args) => {
Comment thread
richardpringle marked this conversation as resolved.
commands::deploy::approve::run(args, non_interactive).await
}
DeployCommands::GetStatus(args) => commands::deploy::get_status::run(args).await,
DeployCommands::ProvisioningDetails(args) => {
commands::deploy::provisioning_details::run(args).await
}
DeployCommands::PostShare(args) => commands::deploy::post_share::run(args).await,
DeployCommands::Status(args) => commands::deploy::status::run(args).await,
DeployCommands::Create(args) => commands::deploy::create::run(args).await,
DeployCommands::Init(args) => commands::deploy::init::run(args).await,
DeployCommands::Create(args) => {
commands::deploy::create::run(args, non_interactive).await
}
DeployCommands::Init(args) => {
commands::deploy::init::run(args, non_interactive).await
}
DeployCommands::Delete(args) => commands::deploy::delete::run(args).await,
DeployCommands::Restore(args) => commands::deploy::restore::run(args).await,
},
Commands::App { command } => match command {
AppCommands::Status(args) => commands::app::status::run(args).await,
AppCommands::List(args) => commands::app::list::run(args).await,
AppCommands::Create(args) => commands::app::create::run(args).await,
AppCommands::Init(args) => commands::app::init::run(args).await,
AppCommands::Create(args) => {
commands::app::create::run(args, non_interactive).await
}
AppCommands::Init(args) => commands::app::init::run(args, non_interactive).await,
AppCommands::SetLiveDeploy(args) => commands::app::set_live_deploy::run(args).await,
AppCommands::Delete(args) => commands::app::delete::run(args).await,
},
Expand All @@ -75,7 +103,7 @@ impl Cli {
commands::keys::re_encrypt_share::run(args).await
}
},
Commands::Login(args) => commands::login::run(args).await,
Commands::Login(args) => commands::login::run(args, non_interactive).await,
}
}
}
Expand Down
Loading
Loading