Skip to content

Commit

Permalink
feat(cli/changelog): implement changelog command
Browse files Browse the repository at this point in the history
  • Loading branch information
comfysage committed Feb 1, 2024
1 parent 61a251c commit 5f94b1a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions saku-cli/src/changelog.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use saku_lib::prelude::*;

use saku_lib::exec;
use saku_lib::util::msg;
use saku_lib::util::path;

pub fn changelog(name: &str) -> Result<()> {
msg::changelog(name, &path::repo(name));

exec::changelog(name)?;

Ok(())
}
1 change: 1 addition & 0 deletions saku-cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod env;
pub mod config;
pub mod show;
pub mod changelog;
pub mod search;
pub mod install;
pub mod add;
Expand Down
4 changes: 4 additions & 0 deletions saku-lib/util/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ pub fn remove(name: &str) {
pub fn add_flask(name: &str, url: &str) {
println!("{}", format!("adding flask {} from {}", general::name_f(name), general::url_f(url)))
}

pub fn changelog(name: &str, path: &str) {
println!("{}", format!("showing changes for {} at {COLOR_BLUE}{}{COLOR_RESET}", general::name_f(name), path))
}
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ fn get_commands() -> Command {
.arg(arg!(<NAME> ... "Package to install")),
)
)
.subcommand(
Command::new("changelog")
.about("show package changelog")
.arg_required_else_help(false)
.arg(arg!([NAME] "Package name"))
)
}

fn main() -> Result<()> {
Expand Down Expand Up @@ -321,6 +327,13 @@ fn main() -> Result<()> {
(&_, _) => Err(Error::Unexpected),
}
}
Some(("changelog", sub_matches)) => {
let name: String = sub_matches
.get_one::<String>("NAME").map_or("saku".to_string(), |v| v.to_owned());

cli::changelog::changelog(&name)?;
Ok(())
}
// If all subcommands are defined above, anything else is unreachable!()
_ => {
Err(make_err!(Missing, "missing command. run saku --help."))
Expand Down

0 comments on commit 5f94b1a

Please sign in to comment.