diff --git a/saku-cli/src/changelog.rs b/saku-cli/src/changelog.rs new file mode 100644 index 0000000..948a0fa --- /dev/null +++ b/saku-cli/src/changelog.rs @@ -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(()) +} diff --git a/saku-cli/src/lib.rs b/saku-cli/src/lib.rs index 35ed05a..6f95f90 100644 --- a/saku-cli/src/lib.rs +++ b/saku-cli/src/lib.rs @@ -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; diff --git a/saku-lib/util/msg.rs b/saku-lib/util/msg.rs index 8919c96..59989b7 100644 --- a/saku-lib/util/msg.rs +++ b/saku-lib/util/msg.rs @@ -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)) +} diff --git a/src/main.rs b/src/main.rs index 6290206..a1f3fbc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -134,6 +134,12 @@ fn get_commands() -> Command { .arg(arg!( ... "Package to install")), ) ) + .subcommand( + Command::new("changelog") + .about("show package changelog") + .arg_required_else_help(false) + .arg(arg!([NAME] "Package name")) + ) } fn main() -> Result<()> { @@ -321,6 +327,13 @@ fn main() -> Result<()> { (&_, _) => Err(Error::Unexpected), } } + Some(("changelog", sub_matches)) => { + let name: String = sub_matches + .get_one::("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."))