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

Make workspace possibly user defined #155

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
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
33 changes: 22 additions & 11 deletions rinex-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ impl Cli {
.help("Input RINEX file")
.action(ArgAction::Append)
.required(true))
.next_help_heading("General")
.arg(Arg::new("quiet")
.short('q')
.long("quiet")
.action(ArgAction::SetTrue)
.help("Disable all terminal output. Also disables auto HTML reports opener."))
.arg(Arg::new("pretty")
.short('p')
.long("pretty")
.action(ArgAction::SetTrue)
.help("Make terminal output more readable."))
.arg(Arg::new("workspace")
.short('w')
.long("workspace")
.value_name("[FOLDER]")
.help("Customize workspace location (folder does not have to exist).
The default workspace is rinex-cli/workspace"))
.next_help_heading("Data identification")
.arg(Arg::new("epochs")
.long("epochs")
Expand Down Expand Up @@ -242,17 +259,7 @@ For example -fp was filtered and decimated, use --output to dump results into a
.help("Custom header attributes, in case we're generating data.
--custom-header must either be plain JSON or an external JSON descriptor.
Refer to README"))
.next_help_heading("Terminal (options)")
.arg(Arg::new("quiet")
.short('q')
.action(ArgAction::SetTrue)
.help("Disable all terminal output. Disable auto HTML opener, on HTML rendering."))
.arg(Arg::new("pretty")
.short('p')
.long("pretty")
.action(ArgAction::SetTrue)
.help("Make terminal output more readable"))
.get_matches()
.get_matches()
},
}
}
Expand Down Expand Up @@ -439,6 +446,10 @@ Refer to README"))
pub fn nav_path(&self) -> Option<&String> {
self.matches.get_one::<String>("nav")
}
/// Returns WORKSPACE prefix to be used
pub fn workspace_prefix(&self) -> Option<&String> {
self.matches.get_one::<String>("workspace")
}
pub fn atx_path(&self) -> Option<&String> {
self.matches.get_one::<String>("atx")
}
Expand Down
23 changes: 15 additions & 8 deletions rinex-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,23 @@ extern crate log;
use fops::open_with_web_browser;
use sp3::{prelude::SP3, Merge as SP3Merge};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::path::PathBuf;

/*
* Workspace location is fixed to rinex-cli/product/$primary
* at the moment
*/
fn workspace_path(ctx: &QcContext) -> PathBuf {
fn workspace_path(ctx: &QcContext, cli: &Cli) -> PathBuf {
let mut path = PathBuf::new();
if let Some(prefix) = cli.workspace_prefix() {
path.push(prefix);
} else {
path.push(env!("CARGO_MANIFEST_DIR"));
path.push("workspace");
}
/*
* grab file name
*/
let primary_stem: &str = ctx
.primary_path()
.file_stem()
Expand All @@ -49,10 +59,7 @@ fn workspace_path(ctx: &QcContext) -> PathBuf {
* Can use .file_name() once https://github.com/rust-lang/rust/issues/86319 is stabilized
*/
let primary_stem: Vec<&str> = primary_stem.split(".").collect();

Path::new(env!("CARGO_MANIFEST_DIR"))
.join("workspace")
.join(primary_stem[0])
path.join(primary_stem[0])
}

/*
Expand Down Expand Up @@ -180,7 +187,7 @@ pub fn main() -> Result<(), rinex::Error> {
let mut ctx = create_context(&cli);

// Workspace
let workspace = workspace_path(&ctx);
let workspace = workspace_path(&ctx, &cli);
info!("workspace is \"{}\"", workspace.to_string_lossy());
create_workspace(workspace.clone());

Expand Down Expand Up @@ -435,7 +442,7 @@ pub fn main() -> Result<(), rinex::Error> {
* Render Graphs (HTML)
*/
if !qc_only {
let html_path = workspace_path(&ctx).join("graphs.html");
let html_path = workspace_path(&ctx, &cli).join("graphs.html");
let html_path = html_path.to_str().unwrap();

let mut html_fd = std::fs::File::create(html_path)
Expand Down
Loading