Skip to content

Commit

Permalink
chore: remaplace structopts with clap
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Jan 25, 2024
1 parent 8924820 commit 41d5119
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 78 deletions.
165 changes: 97 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ codegen-units = 1
lto = true

[features]
default = ["iced/wgpu", "iced/palette", "cli"]
cli = ["structopt"]
default = ["iced/wgpu", "iced/palette"]
debug = ["iced/debug"]

[dependencies]
Expand All @@ -32,7 +31,7 @@ tokio = { version = "1.29.1", features = ["process", "macros", "io-util"] }
sled = "0.34.7"

onagre-launcher-toolkit = "0.1.1"
structopt = { version = "^0", default-features = false, optional = true }
clap = { version = "^4", features = ["derive"] }
freedesktop-icons = "0.2.5"

log = { version = "^0.4" }
Expand Down
12 changes: 5 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use std::path::PathBuf;

use anyhow::anyhow;
use app::style::Theme;
use clap::Parser;
use log::{info, LevelFilter};
use once_cell::sync::Lazy;
use std::sync::Mutex;
use structopt::StructOpt;
use systemd_journal_logger::JournalLog;

pub mod app;
Expand All @@ -25,14 +25,12 @@ pub static THEME_PATH: Lazy<Mutex<PathBuf>> = Lazy::new(|| {

pub static THEME: Lazy<Theme> = Lazy::new(Theme::load);

#[derive(StructOpt)]
#[derive(Parser)]
#[structopt(name = "onagre", author = "Paul D. <paul.delafosse@protonmail.com>")]
struct Cli {
#[structopt(
name = "theme",
short = "t",
#[arg(
long = "theme",
takes_value = true,
short = 't',
help = "Path to an alternate onagre theme file"
)]
theme: Option<PathBuf>,
Expand All @@ -42,7 +40,7 @@ pub fn main() -> iced::Result {
JournalLog::new().unwrap().install().unwrap();
log::set_max_level(LevelFilter::Info);
info!("Starting onagre");
let cli = Cli::from_args();
let cli = Cli::parse();
// User defined theme config, $XDG_CONFIG_DIR/onagre/theme.toml otherwise
if let Some(theme_path) = cli.theme {
let path = theme_path.canonicalize();
Expand Down

0 comments on commit 41d5119

Please sign in to comment.