-
Notifications
You must be signed in to change notification settings - Fork 2
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
3 changed files
with
39 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
BASE_URL="http://localhost:8080/api/v1/judge" | ||
RUST_LOG=DEBUG |
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,31 @@ | ||
use structopt::StructOpt; | ||
|
||
#[derive(StructOpt, Debug, Clone)] | ||
#[structopt(name = "judge-client")] | ||
pub struct JudgeClientOpt { | ||
#[structopt(long)] | ||
pub env_path: Option<String>, | ||
|
||
/// Port to listen to | ||
#[structopt(env = "BASE_URL", default_value = "http://localhost:8080/api/v1/judge")] | ||
pub base_url: String, | ||
} | ||
|
||
pub fn load_option() -> JudgeClientOpt { | ||
// First load env_path from Args | ||
let opt = JudgeClientOpt::from_args(); | ||
if let Some(env_path) = opt.env_path { | ||
dotenv::from_path(env_path).ok(); | ||
} else { | ||
dotenv::dotenv().ok(); | ||
} | ||
|
||
// Load opt again with ENV | ||
let opt = JudgeClientOpt::from_args(); | ||
log::debug!("load opt: {:?}", opt); | ||
opt | ||
} | ||
|
||
pub fn setup_logger() { | ||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")).init(); | ||
} |
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