-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
4,626 additions
and
217 deletions.
There are no files selected for viewing
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 +1 @@ | ||
/target | ||
**/target |
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,16 @@ | ||
[package] | ||
name = "logger" | ||
version = "0.1.0" | ||
authors = ["Jarrod Overson <jsoverson@gmail.com>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
chrono = "0.4.19" | ||
colored = "2.0.0" | ||
log = "0.4.11" | ||
env_logger = "0.8.3" | ||
anyhow = "1.0.40" | ||
serde_json = "1.0.64" | ||
structopt = "0.3.21" |
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,48 @@ | ||
use anyhow::anyhow; | ||
use env_logger::WriteStyle; | ||
use structopt::StructOpt; | ||
|
||
fn parse_write_style(spec: &str) -> anyhow::Result<WriteStyle> { | ||
match spec { | ||
"auto" => Ok(WriteStyle::Auto), | ||
"always" => Ok(WriteStyle::Always), | ||
"never" => Ok(WriteStyle::Never), | ||
_ => Err(anyhow!("Configuration error")), | ||
} | ||
} | ||
|
||
#[derive(StructOpt, Debug, Clone)] | ||
pub struct LoggingOptions { | ||
/// Disables logging | ||
#[structopt(long = "quiet", short = "q")] | ||
pub quiet: bool, | ||
|
||
/// Outputs the version | ||
#[structopt(long = "version", short = "v")] | ||
pub version: bool, | ||
|
||
/// Turns on verbose logging | ||
#[structopt(long = "verbose", short = "V")] | ||
pub verbose: bool, | ||
|
||
/// Turns on debug logging | ||
#[structopt(long = "debug")] | ||
pub debug: bool, | ||
|
||
/// Turns on trace logging | ||
#[structopt(long = "trace")] | ||
pub trace: bool, | ||
|
||
/// Log as JSON | ||
#[structopt(long = "json")] | ||
pub json: bool, | ||
|
||
/// Log style | ||
#[structopt( | ||
long = "log-style", | ||
env = "VINO_LOG_STYLE", | ||
parse(try_from_str = parse_write_style), | ||
default_value="auto" | ||
)] | ||
pub log_style: WriteStyle, | ||
} |
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,17 @@ | ||
[package] | ||
name = "vino-configfile" | ||
version = "0.1.0" | ||
authors = ["Jarrod Overson <jsoverson@gmail.com>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
serde = { version = "1.0.126", features = ["derive"] } | ||
config = "0.11.0" | ||
directories-next = "2.0.0" | ||
log = "0.4.14" | ||
toml = "0.5.8" | ||
|
||
[dev-dependencies] | ||
env_logger = "" |
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,40 @@ | ||
use std::{io, path::PathBuf}; | ||
|
||
use directories_next::BaseDirs; | ||
use serde::Deserialize; | ||
#[derive(Debug, Deserialize, Default)] | ||
pub struct VinoConfig { | ||
pub cache_dir: Option<String>, | ||
} | ||
|
||
fn load_configfile<T: AsRef<str>>(file: T) -> VinoConfig { | ||
let mut dir = match BaseDirs::new() { | ||
Some(base_dirs) => base_dirs.home_dir().to_path_buf(), | ||
None => PathBuf::new(), | ||
}; | ||
|
||
dir.push(file.as_ref()); | ||
if let Ok(result) = std::fs::read_to_string(dir) { | ||
let config: VinoConfig = toml::from_str(&result).unwrap_or_default(); | ||
|
||
println!("{:?}", config); | ||
config | ||
} else { | ||
VinoConfig::default() | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
|
||
use crate::load_configfile; | ||
fn init() { | ||
env_logger::init(); | ||
} | ||
#[test] | ||
fn runs_crud_api_config() { | ||
init(); | ||
let config = load_configfile(".vinocfg"); | ||
println!("{:?}", config); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
crates/vino-runtime2/Cargo.toml → crates/vino-runtime/Cargo.toml
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.