-
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.
feat: Add command line arguments support
- Loading branch information
1 parent
85a11c6
commit 6b3bf3c
Showing
5 changed files
with
80 additions
and
12 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,35 @@ | ||
use clap::Parser; | ||
use std::sync::OnceLock; | ||
|
||
#[derive(clap::Parser, Debug)] | ||
#[command(version, about, long_about = None)] | ||
struct Args { | ||
/// Enable experimental features | ||
#[arg(long)] | ||
experimental: bool, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Config { | ||
#[allow(dead_code)] | ||
pub experimental: bool, | ||
pub process_neighbours: bool, | ||
} | ||
|
||
impl Default for Config { | ||
fn default() -> Self { | ||
Self { | ||
experimental: false, | ||
process_neighbours: true, | ||
} | ||
} | ||
} | ||
|
||
pub static CONFIG: OnceLock<Config> = OnceLock::new(); | ||
|
||
pub fn get() -> &'static Config { | ||
CONFIG.get_or_init(|| Config { | ||
experimental: Args::parse().experimental, | ||
..Default::default() | ||
}) | ||
} |
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
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