Skip to content

Commit

Permalink
cli: pass down the cli the branch arg
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Apr 14, 2024
1 parent 63ca832 commit 8170661
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion coffee_cmd/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ pub enum CoffeeCommand {
verbose: bool,
#[arg(short, long, action = clap::ArgAction::SetTrue)]
dynamic: bool,
#[arg(short, long)]
branch: Option<String>,
},
/// upgrade a single repository.
#[clap(arg_required_else_help = true)]
Expand Down Expand Up @@ -96,9 +98,10 @@ impl From<&CoffeeCommand> for coffee_core::CoffeeOperation {
match value {
CoffeeCommand::Install {
plugin,
branch,
verbose,
dynamic,
} => Self::Install(plugin.to_owned(), *verbose, *dynamic),
} => Self::Install(plugin.to_owned(), branch.clone(), *verbose, *dynamic),
CoffeeCommand::Upgrade { repo, verbose } => Self::Upgrade(repo.to_owned(), *verbose),
CoffeeCommand::List {} => Self::List,
CoffeeCommand::Setup { cln_conf } => Self::Setup(cln_conf.to_owned()),
Expand Down
3 changes: 2 additions & 1 deletion coffee_cmd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async fn run(args: CoffeeArgs, mut coffee: CoffeeManager) -> Result<(), CoffeeEr
match args.command {
CoffeeCommand::Install {
plugin,
branch,
verbose,
dynamic,
} => {
Expand All @@ -26,7 +27,7 @@ async fn run(args: CoffeeArgs, mut coffee: CoffeeManager) -> Result<(), CoffeeEr
} else {
None
};
match coffee.install(&plugin, verbose, dynamic).await {
match coffee.install(&plugin, branch, verbose, dynamic).await {
Ok(_) => {
spinner.and_then(|spinner| Some(spinner.finish()));
term::success!("Plugin {plugin} Compiled and Installed")
Expand Down
3 changes: 2 additions & 1 deletion coffee_core/src/coffee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ impl PluginManager for CoffeeManager {
async fn install(
&mut self,
plugin: &str,
branch: Option<String>,
verbose: bool,
try_dynamic: bool,
) -> Result<(), CoffeeError> {
Expand Down Expand Up @@ -407,7 +408,7 @@ impl PluginManager for CoffeeManager {
UpgradeStatus::Updated(_, _) => {
for plugins in status.plugins_effected.iter() {
self.remove(plugins).await?;
self.install(plugins, verbose, false).await?;
self.install(plugins, None, verbose, false).await?;
}
}
_ => {}
Expand Down
4 changes: 2 additions & 2 deletions coffee_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ pub use coffee_lib as lib;

#[derive(Clone, Debug)]
pub enum CoffeeOperation {
/// Install(plugin name, verbose run, dynamic installation)
Install(String, bool, bool),
/// Install(plugin name, branch, verbose run, dynamic installation)
Install(String, Option<String>, bool, bool),
/// List
List,
// Upgrade(name of the repository, verbose run)
Expand Down
2 changes: 1 addition & 1 deletion coffee_httpd/src/httpd/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async fn coffee_install(
let try_dynamic = body.try_dynamic;

let mut coffee = data.coffee.lock().await;
let result = coffee.install(plugin, false, try_dynamic).await;
let result = coffee.install(plugin, None, false, try_dynamic).await;

handle_httpd_response!(result, "Plugin '{plugin}' installed successfully")
}
Expand Down
1 change: 1 addition & 0 deletions coffee_lib/src/plugin_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub trait PluginManager {
async fn install(
&mut self,
plugins: &str,
branch: Option<String>,
verbose: bool,
try_dynamic: bool,
) -> Result<(), CoffeeError>;
Expand Down
2 changes: 1 addition & 1 deletion coffee_plugin/src/plugin/plugin_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn coffee_install(plugin: &mut Plugin<State>, request: Value) -> Result<Value, P
let rt = Runtime::new().unwrap();

let request: InstallReq = serde_json::from_value(request)?;
rt.block_on(coffee.install(&request.name, false, true))
rt.block_on(coffee.install(&request.name, None, false, true))
.map_err(from)?;
Ok(json!({}))
}
Expand Down

0 comments on commit 8170661

Please sign in to comment.