Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve CLI texts and flags #342

Merged
merged 3 commits into from
Oct 14, 2022
Merged
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
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