summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorDavid Karrick <48275422+Th3Whit3Wolf@users.noreply.github.com>2021-01-27 21:24:27 +0000
committerGitHub <noreply@github.com>2021-01-27 22:24:27 +0100
commit530e077fe772daee96d3f7a88259b82957960c9d (patch)
tree9dd97ec6b29182586cf73cbafed5880f843610d3 /src/main.rs
parentffdee4410537f9dcfcfa2589765f9a9081a98bd6 (diff)
Allow user to set theme with flag (#481)
closes #480
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 560d52ee..e1e45ec0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -73,8 +73,12 @@ pub enum QueueEvent {
InputEvent(InputEvent),
}
+struct CliArgs {
+ theme: PathBuf,
+}
+
fn main() -> Result<()> {
- process_cmdline()?;
+ let cliargs = process_cmdline()?;
let _profiler = Profiler::new();
@@ -100,7 +104,7 @@ fn main() -> Result<()> {
let ticker = tick(TICK_INTERVAL);
let spinner_ticker = tick(SPINNER_INTERVAL);
- let mut app = App::new(&tx_git, input);
+ let mut app = App::new(&tx_git, input, cliargs.theme);
let mut spinner = Spinner::default();
let mut first_update = true;
@@ -261,12 +265,20 @@ fn setup_logging() -> Result<()> {
Ok(())
}
-fn process_cmdline() -> Result<()> {
+fn process_cmdline() -> Result<CliArgs> {
let app = ClapApp::new(crate_name!())
.author(crate_authors!())
.version(crate_version!())
.about(crate_description!())
.arg(
+ Arg::with_name("theme")
+ .help("Set the color theme (defaults to theme.ron)")
+ .short("t")
+ .long("theme")
+ .value_name("THEME")
+ .takes_value(true),
+ )
+ .arg(
Arg::with_name("logging")
.help("Stores logging output into a cache directory")
.short("l")
@@ -290,8 +302,17 @@ fn process_cmdline() -> Result<()> {
arg_matches.value_of("directory").unwrap_or(".");
env::set_current_dir(directory)?;
}
-
- Ok(())
+ let arg_theme =
+ arg_matches.value_of("theme").unwrap_or("theme.ron");
+ if get_app_config_path()?.join(arg_theme).is_file() {
+ Ok(CliArgs {
+ theme: get_app_config_path()?.join(arg_theme),
+ })
+ } else {
+ Ok(CliArgs {
+ theme: get_app_config_path()?.join("theme.ron"),
+ })
+ }
}
fn set_panic_handlers() -> Result<()> {