Skip to content

Commit

Permalink
feat: improve CLI texts and flags (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
faassen committed Oct 14, 2022
1 parent b18b6c8 commit 9e0a03e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions iroh/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ use iroh_metrics::config::Config as MetricsConfig;
pub struct Cli {
#[clap(long)]
cfg: Option<PathBuf>,
/// Track metrics
#[clap(long, action = clap::ArgAction::Set, default_value_t=true)]
metrics: bool,
/// Do not track metrics
#[clap(long)]
no_metrics: bool,
#[clap(subcommand)]
command: Commands,
}

impl Cli {
fn make_overrides_map(&self) -> HashMap<String, String> {
let mut map = HashMap::new();
map.insert("metrics.debug".to_string(), (!self.metrics).to_string());
map.insert("metrics.debug".to_string(), (self.no_metrics).to_string());
map
}
}
Expand All @@ -39,22 +39,23 @@ enum Commands {
watch: bool,
},
P2p(P2p),
#[clap(about = "break up a file into block and provide those blocks on the ipfs network")]
#[clap(about = "Add a file or directory to iroh & make it available on IPFS")]
Add {
/// The path to a file or directory to be added
path: PathBuf,
/// Required to add a directory
#[clap(long, short)]
recursive: bool,
#[clap(long, short)]
/// Do not wrap added content with a directory
#[clap(long)]
no_wrap: bool,
},
#[clap(
about = "get content based on a Content Identifier from the ipfs network, and save it "
)]
#[clap(about = "Fetch IPFS content and write it to disk")]
Get {
/// CID or CID/with/path/qualifier to get
ipfs_path: IpfsPath,
/// filesystem path to write to. Defaults to CID
output_path: Option<PathBuf>,
/// filesystem path to write to. Optional and defaults to $CID
output: Option<PathBuf>,
},
}

Expand Down Expand Up @@ -110,10 +111,10 @@ impl Cli {
println!("/ipfs/{}", cid);
}
Commands::Get {
ipfs_path,
output_path,
ipfs_path: path,
output,
} => {
let root_path = api.get(ipfs_path, output_path.as_deref()).await?;
let root_path = api.get(path, output.as_deref()).await?;
println!("Saving file(s) to {}", root_path.to_str().unwrap());
}
};
Expand Down

0 comments on commit 9e0a03e

Please sign in to comment.