Skip to content

Commit

Permalink
feat: Move --keylog to common flags (#776)
Browse files Browse the repository at this point in the history
All subcommands take this option, so repeating it like that is a bit
silly.  Move it to the toplevel.
  • Loading branch information
flub committed Feb 21, 2023
1 parent e3012f0 commit feeefa9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

26 changes: 7 additions & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ use iroh::{get, provider, Hash, Keypair, PeerId};
struct Cli {
#[clap(subcommand)]
command: Commands,
/// Log SSL pre-master key to file in SSLKEYLOGFILE environment variable.
#[clap(long)]
keylog: bool,
}

#[derive(Subcommand, Debug, Clone)]
Expand All @@ -39,9 +42,6 @@ enum Commands {
/// If this path is provided and it exists, the private key is read from this file and used, if it does not exist the private key will be persisted to this location.
#[clap(long)]
key: Option<PathBuf>,
/// Log SSL pre-master key to file in SSLKEYLOGFILE environment variable.
#[clap(long)]
keylog: bool,
},
/// Fetch some data by hash.
#[clap(about = "Fetch the data from the hash")]
Expand All @@ -60,9 +60,6 @@ enum Commands {
/// Optional path to a new directory in which to save the file(s). If none is specified writes the data to STDOUT.
#[clap(long, short)]
out: Option<PathBuf>,
/// Log SSL pre-master key to file in SSLKEYLOGFILE environment variable.
#[clap(long)]
keylog: bool,
},
/// Fetches some data from a ticket,
///
Expand All @@ -78,9 +75,6 @@ enum Commands {
out: Option<PathBuf>,
/// Ticket containing everything to retrieve a hash from provider.
ticket: Ticket,
/// Log SSL pre-master key to file in SSLKEYLOGFILE environment variable.
#[clap(long)]
keylog: bool,
},
}

Expand Down Expand Up @@ -214,11 +208,10 @@ async fn main() -> Result<()> {
token,
addr,
out,
keylog,
} => {
let mut opts = get::Options {
peer_id: Some(peer),
keylog,
keylog: cli.keylog,
..Default::default()
};
if let Some(addr) = addr {
Expand All @@ -237,11 +230,7 @@ async fn main() -> Result<()> {
}
}
}
Commands::GetTicket {
out,
ticket,
keylog,
} => {
Commands::GetTicket { out, ticket } => {
let Ticket {
hash,
peer,
Expand All @@ -251,7 +240,7 @@ async fn main() -> Result<()> {
let opts = get::Options {
addr,
peer_id: Some(peer),
keylog,
keylog: cli.keylog,
};
tokio::select! {
biased;
Expand All @@ -269,11 +258,10 @@ async fn main() -> Result<()> {
addr,
auth_token,
key,
keylog,
} => {
tokio::select! {
biased;
res = provide_interactive(path, addr, auth_token, key, keylog) => {
res = provide_interactive(path, addr, auth_token, key, cli.keylog) => {
res
}
_ = tokio::signal::ctrl_c() => {
Expand Down

0 comments on commit feeefa9

Please sign in to comment.