Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop indoc dependency and improve style #212

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ exclude = ["tests/07a-mount-point-excl", "tests/10-example"]

[dependencies]
anyhow = "1.0.12"
clap = { version = "4.5", default-features = false, features = ["std", "cargo", "help" , "error-context"] }
clap = { version = "4.5", default-features = false, features = ["std", "cargo", "help", "error-context"] }
liboverdrop = "0.1.0"
rust-ini = ">=0.15, <0.18"
log = { version = "0.4", features = ["std"] }
fasteval = { version = "0.2", default-features = false }
indoc = "2.0.5"

[dev-dependencies]
tempfile = "3"
Expand Down
23 changes: 11 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod kernlog;
mod setup;

use anyhow::Result;
use indoc::indoc;
use log::{info, LevelFilter};
use std::borrow::Cow;
use std::env;
Expand All @@ -25,11 +24,11 @@ enum Opts {
#[rustfmt::skip]
fn command() -> clap::Command {
clap::command!()
.override_usage(indoc! {"
zram-generator --setup-device <device>
zram-generator --reset-device <device>
zram-generator dir1 [dir2 dir3]
"})
.override_usage("\
\tzram-generator --setup-device <device>\n\
\tzram-generator --reset-device <device>\n\
\tzram-generator dir1 [dir2 dir3]\
")
.arg(
clap::arg!(--"setup-device" <device> "Set up a single device")
.conflicts_with("reset-device")
Expand All @@ -50,13 +49,13 @@ fn command() -> clap::Command {
fn get_opts() -> Opts {
let opts = command().get_matches();

if let Some(val) = opts.get_one::<String>("setup-device") {
Opts::SetupDevice(val.clone())
} else if let Some(val) = opts.get_one::<String>("reset-device") {
Opts::ResetDevice(val.clone())
if let Some(val) = opts.get_one::<&str>("setup-device") {
Opts::SetupDevice(val.to_string())
} else if let Some(val) = opts.get_one::<&str>("reset-device") {
Opts::ResetDevice(val.to_string())
} else {
let val = opts.get_one::<String>("dir").expect("clap invariant");
Opts::GenerateUnits(val.clone())
let val = opts.get_one::<&str>("dir").expect("clap invariant");
Opts::GenerateUnits(val.to_string())
}
}

Expand Down