Skip to content

Commit

Permalink
Update to trane v0.14.2 and implement new features (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmr authored May 29, 2023
1 parent b3bac84 commit d8df95c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "trane-cli"
version = "0.14.1"
version = "0.14.2"
build = "build.rs"
default-run = "trane"

Expand All @@ -23,7 +23,7 @@ rustyline = "11.0.0"
rustyline-derive = "0.8.0"
serde_json = "1.0.93"
termimad = "0.22.0"
trane = "0.14.1"
trane = "0.14.2"
ustr = { version = "0.9.0", features = ["serialization"] }
# Commented out for use in local development.
# trane = { path = "../trane" }
Expand Down
14 changes: 13 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ impl TraneApp {
}

/// Removes the given unit from the blacklist.
pub fn whitelist(&mut self, unit_id: &Ustr) -> Result<()> {
pub fn remove_from_blacklist(&mut self, unit_id: &Ustr) -> Result<()> {
ensure!(self.trane.is_some(), "no Trane instance is open");

self.trane
Expand All @@ -967,6 +967,18 @@ impl TraneApp {
Ok(())
}

/// Removes the given unit from the blacklist.
pub fn remove_prefix_from_blacklist(&mut self, prefix: &str) -> Result<()> {
ensure!(self.trane.is_some(), "no Trane instance is open");

self.trane
.as_mut()
.unwrap()
.remove_prefix_from_blacklist(prefix)?;
self.reset_batch();
Ok(())
}

/// Adds a new repository to the Trane instance.
pub fn add_repo(&mut self, url: &str, repo_id: Option<String>) -> Result<()> {
ensure!(self.trane.is_some(), "no Trane instance is open");
Expand Down
14 changes: 13 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ pub(crate) enum BlacklistSubcommands {
#[clap(help = "The unit to remove from the blacklist")]
unit_id: Ustr,
},

#[clap(about = "Removes all the units that match the given prefix from the blacklist")]
RemovePrefix {
#[clap(help = "The prefix to remove from the blacklist")]
prefix: String,
},
}

/// Contains subcommands used for debugging.
Expand Down Expand Up @@ -482,11 +488,17 @@ impl TraneCli {
}

Subcommands::Blacklist(BlacklistSubcommands::Remove { unit_id }) => {
app.whitelist(&unit_id)?;
app.remove_from_blacklist(&unit_id)?;
println!("Removed {unit_id} from the blacklist");
Ok(true)
}

Subcommands::Blacklist(BlacklistSubcommands::RemovePrefix { prefix }) => {
app.remove_prefix_from_blacklist(&prefix)?;
println!("Removed units matching prefix {prefix} from the blacklist");
Ok(true)
}

Subcommands::Blacklist(BlacklistSubcommands::List) => {
app.list_blacklist()?;
Ok(true)
Expand Down

0 comments on commit d8df95c

Please sign in to comment.