Skip to content

Commit

Permalink
goat taxon/assembly search/count get -U flag to print the GoaT URL to…
Browse files Browse the repository at this point in the history
… the terminal window.
  • Loading branch information
Euphrasiologist committed Jul 1, 2022
1 parent b127c63 commit aa7f2e9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ async fn main() -> Result<()> {
.long("url")
.help("Print the underlying GoaT API URL(s). Useful for debugging."),
)
.arg(
Arg::new("goat-ui-url")
.short('U')
.long("goat-ui-url")
.help("Print the underlying GoaT UI URL(s). View on the browser!"),
)
};

let assembly_search_and_count = |name, about| {
Expand Down Expand Up @@ -377,6 +383,12 @@ async fn main() -> Result<()> {
.long("url")
.help("Print the underlying GoaT API URL(s). Useful for debugging."),
)
.arg(
Arg::new("goat-ui-url")
.short('U')
.long("goat-ui-url")
.help("Print the underlying GoaT UI URL(s). View on the browser!"),
)
};

// actually parse the matches.
Expand Down
5 changes: 1 addition & 4 deletions src/report/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ pub struct Report {
pub search: Vec<String>,
/// The rank of the return type.
pub rank: String,
///
pub url: bool,
}

impl Report {
Expand All @@ -28,7 +26,6 @@ impl Report {
// simply return the populated struct
// taxon, url, rank
let search_op = matches.value_of("taxon");
let url = matches.is_present("url");
// safe to unwrap, as default is defined.
let rank = matches.value_of("rank").unwrap().to_string();

Expand All @@ -38,7 +35,7 @@ impl Report {
None => bail!("There was no taxon input."),
};

Ok(Self { search, rank, url })
Ok(Self { search, rank })
}

/// Make the URL. Currently only [`RecordType::Newick`] supported.
Expand Down
8 changes: 8 additions & 0 deletions src/utils/cli_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn process_cli_args(
) -> Result<(u64, Vec<String>, Vec<String>)> {
// command line args same between taxon/assembly
let print_url = matches.is_present("url");
let print_goat_ui_url = matches.is_present("goat-ui-url");
let tax_tree_enum = match matches.is_present("descendents") {
true => TaxType::Tree,
false => TaxType::Name,
Expand Down Expand Up @@ -221,6 +222,13 @@ pub fn process_cli_args(
println!("{}.\tGoaT API URL: {}", index, url);
}
std::process::exit(0);
} else if print_goat_ui_url {
for (index, url) in url_vector_api.iter().enumerate() {
// remove api/v2/
let new_url = url.replace("api/v2/", "");
println!("{}.\tGoaT API URL: {}", index, new_url);
}
std::process::exit(0);
}

// return the url vector
Expand Down

0 comments on commit aa7f2e9

Please sign in to comment.