Skip to content

Commit

Permalink
default taxo path
Browse files Browse the repository at this point in the history
  • Loading branch information
dagou committed Sep 9, 2024
1 parent 8dd9aec commit dc87a40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 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.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clade"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
description = "A tool for phlyo tree, a phylogenetic tree construction software."
license = "MIT"
Expand Down
16 changes: 15 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use clade::ncbi;
use clade::taxo::{prune_taxonomy, prune_taxonomy_by_names, Taxonomy};
use clade::update::update_taxdump;
use clap::{Parser, Subcommand};
use std::env;
use std::{error::Error, fs::File, io::Write, path::PathBuf};

#[derive(clap::Parser, Debug)]
Expand All @@ -14,10 +15,23 @@ struct Args {
#[clap(subcommand)]
pub cmd: Command,

#[clap(short, long, help = "The path to store the taxdump files")]
#[clap(
short,
long,
help = "The path to store the taxdump files",
default_value_os_t = default_taxo_path()
)]
pub taxo_path: PathBuf,
}

fn default_taxo_path() -> PathBuf {
env::var_os("HOME")
.or_else(|| env::var_os("USERPROFILE"))
.map(PathBuf::from)
.map(|p| p.join(".clade"))
.unwrap_or_else(|| PathBuf::from(".clade"))
}

#[derive(Subcommand, Debug)]
enum Command {
#[clap(about = "Update NCBI taxdump files")]
Expand Down

0 comments on commit dc87a40

Please sign in to comment.