diff --git a/src/main.rs b/src/main.rs index d2d2d40..df0e0b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,7 @@ struct GsContext { github: Arc, state: GsState, } +const VERSION: &str = env!("CARGO_PKG_VERSION"); #[tokio::main] async fn main() -> Result<()> { @@ -60,8 +61,9 @@ async fn main() -> Result<()> { }, Some(Commands::Reset {}) => ctx.reset()?, None => println!( - "Welcome to {}! Run {} to see available commands.", - style("G-Stack v0.0.3").bold().cyan(), + "Welcome to {} version {}! Run {} to see available commands.", + style("G-Stack").bold().cyan(), + style(VERSION).bold().yellow(), style("gs help").italic().green(), ), } @@ -371,13 +373,9 @@ impl GsContext { async fn list_pull_requests(&self) -> Result<()> { let open_pulls = self.get_pull_requests().await?; - println!( - "{:?}", - open_pulls - .iter() - .map(|pr| pr.title.clone().unwrap()) - .collect::>() - ); + for pr in open_pulls.iter() { + println!("#{}: {} ", pr.number, pr.html_url.clone().unwrap()); + } Ok(()) } diff --git a/src/repo_extensions.rs b/src/repo_extensions.rs index 4675ca0..1eccb44 100644 --- a/src/repo_extensions.rs +++ b/src/repo_extensions.rs @@ -1,5 +1,6 @@ use anyhow::Result; use anyhow::{bail, Ok}; +use console::style; use regex::Regex; use std::fmt::Debug; use std::{ops::Rem, str::FromStr}; @@ -18,7 +19,7 @@ pub trait RepoExtenstions { fn remote_repo_url(&self) -> Result; fn remote_repo_info(&self) -> Result; fn force_push_to_upstream(&self, upstream: &str, upstream_branch: &BranchName) -> Result<()>; - fn head_sha(&self, branch_name: &String) -> Result; + fn head_sha(&self, branch_name: &String) -> Result; } impl RepoExtenstions for Repository { @@ -30,15 +31,24 @@ impl RepoExtenstions for Repository { fn rebase(&self, branch: BranchName, on: BranchName) -> Result<()> { self.switch_branch(&branch)?; let output = self.cmd_out(&["rebase", "--update-refs", on.to_string().as_str()])?; - println!("{:?}", output); + println!( + "Rebased branch {} on {} with output: {:?}", + style(branch).green(), + style(on).green(), + style(output.join(",")).white().on_black() + ); Ok(()) } fn pull_all(&self, branches: &Vec) -> Result<()> { for branch in branches { self.switch_branch(&BranchName::from_str(branch.as_str())?)?; - let output = self.cmd_out(&["pull", "--rebase"]).ok(); - println!("{:?}", output); + let output = self.cmd_out(&["pull", "--rebase"])?; + println!( + "Pulled branch {} with output: {:?}", + style(branch).green(), + style(output.join(",")).white().on_black() + ); } Ok(()) } @@ -54,7 +64,6 @@ impl RepoExtenstions for Repository { fn remote_repo_info(&self) -> Result { let url = self.remote_repo_url()?; let re = Regex::new(r"(https://github.com/|git@github.com:)([^/]+)/([^/]+)\.git").unwrap(); - println!("{}", url); if let Some(captures) = re.captures(url.as_str()) { Ok(RemoteRepoInfo { @@ -68,13 +77,18 @@ impl RepoExtenstions for Repository { ///Force push the curent branch to its associated remote, specifying the upstream branch fn force_push_to_upstream(&self, upstream: &str, upstream_branch: &BranchName) -> Result<()> { - self.cmd_out(&[ + let output = self.cmd_out(&[ "push", "-u", upstream, upstream_branch.to_string().as_str(), "--force", - ]); + ])?; + println!( + "Force pushed to upstream branch {} with output: {:?}", + style(upstream_branch).green(), + style(output.join(",")).white().on_black() + ); Ok(()) }