Skip to content

Commit

Permalink
make --sub a required option
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen1Plus committed Aug 10, 2024
1 parent eb260ab commit 485f746
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ enum Commands {

/// The sub-packages to add
#[arg(short, long)]
sub: Option<Vec<String>>,

/// decide whether to install the default sub-themes
#[arg(long)]
no_default: bool,
sub: Vec<String>,
},

/// Remove a theme
Expand Down Expand Up @@ -63,11 +59,7 @@ fn main() {
pkg::Manifest::update().unwrap();
}

Commands::Add {
theme,
sub,
no_default,
} => {
Commands::Add { theme, sub } => {
let pkg = Manifest::get(&theme)
.expect("Theme not found")
.store_package()
Expand All @@ -76,21 +68,7 @@ fn main() {
let mut installed_pkg =
InstalledPackage::get(&theme).unwrap_or_else(|_| pkg.install().unwrap());

let mut subs = if no_default {
Vec::new()
} else {
pkg.default.iter().map(|x| x.to_owned()).collect()
};

if let Some(sub) = sub {
for id in &sub {
if !subs.contains(id) {
subs.push(id.clone());
}
}
}

for id in &subs {
for id in &sub {
installed_pkg.add_sub(id, &pkg).unwrap();
}
installed_pkg.save().unwrap();
Expand Down

0 comments on commit 485f746

Please sign in to comment.