-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from timkolloch/features/command-line-parameters
Added command line parameter parsing
- Loading branch information
Showing
5 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! Holds all the command line parameters and the types associated with them | ||
use clap::Parser; | ||
use log::LevelFilter; | ||
|
||
/// Struct containing all possible command line parameters. | ||
#[derive(Parser, Debug)] | ||
#[command(version, about, long_about = None)] | ||
pub struct Args{ | ||
/// Override existing properties | ||
#[arg(short, long="override", help = "When set the program overrides already present properties.")] | ||
pub override_properties: bool, | ||
|
||
/// Interactive mode | ||
#[arg(short, long, help = "When set the program asks the user to enter a FDC ID when none was found.")] | ||
pub interactive: bool, | ||
|
||
/// Log level | ||
#[arg(short, long, default_value = "info", help = "Sets the log level.",)] | ||
pub log_level: LogLevel, | ||
} | ||
|
||
/// Possible log levels. | ||
#[derive(clap::ValueEnum, Clone, Debug)] | ||
pub enum LogLevel{ | ||
Trace, | ||
Debug, | ||
Info, | ||
Warning, | ||
Error | ||
} | ||
|
||
impl Into<LevelFilter> for LogLevel{ | ||
fn into(self) -> LevelFilter { | ||
match self { | ||
LogLevel::Trace => LevelFilter::Trace, | ||
LogLevel::Debug => LevelFilter::Debug, | ||
LogLevel::Info => LevelFilter::Info, | ||
LogLevel::Warning => LevelFilter::Warn, | ||
LogLevel::Error => LevelFilter::Error | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//! Models to hold objects retrieved from Tandoor or the USDA FDC database and models used to push objects to Tandoor. | ||
pub mod tandoor; | ||
pub mod usda; | ||
pub mod configuration; | ||
pub mod configuration; | ||
pub mod command_line_arguments; |