Fix formatting

This commit is contained in:
Federico Terzi 2020-09-22 21:46:39 +02:00
parent b13745ccd2
commit ff13da9a85
6 changed files with 33 additions and 13 deletions

View File

@ -98,8 +98,13 @@ fn main() {
.required(false) .required(false)
.default_value("hub"), .default_value("hub"),
) )
.arg(Arg::with_name("proxy").help("Use a proxy, should be used as --proxy=https://proxy:1234") .arg(
.required(false).long("proxy").takes_value(true)); Arg::with_name("proxy")
.help("Use a proxy, should be used as --proxy=https://proxy:1234")
.required(false)
.long("proxy")
.takes_value(true),
);
let uninstall_subcommand = SubCommand::with_name("uninstall") let uninstall_subcommand = SubCommand::with_name("uninstall")
.about("Remove an installed package. Equivalent to 'espanso package uninstall'") .about("Remove an installed package. Equivalent to 'espanso package uninstall'")
@ -1103,7 +1108,7 @@ fn install_main(_config_set: ConfigSet, matches: &ArgMatches) {
println!("Using proxy: {}", proxy); println!("Using proxy: {}", proxy);
Some(proxy.to_string()) Some(proxy.to_string())
} }
None => {None} None => None,
}; };
let package_resolver = Box::new(ZipPackageResolver::new()); let package_resolver = Box::new(ZipPackageResolver::new());

View File

@ -49,7 +49,11 @@ pub trait PackageManager {
} }
pub trait PackageResolver { pub trait PackageResolver {
fn clone_repo_to_temp(&self, repo_url: &str, proxy: Option<String>) -> Result<TempDir, Box<dyn Error>>; fn clone_repo_to_temp(
&self,
repo_url: &str,
proxy: Option<String>,
) -> Result<TempDir, Box<dyn Error>>;
} }
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]

View File

@ -13,7 +13,11 @@ impl ZipPackageResolver {
} }
impl super::PackageResolver for ZipPackageResolver { impl super::PackageResolver for ZipPackageResolver {
fn clone_repo_to_temp(&self, repo_url: &str, proxy: Option<String>) -> Result<TempDir, Box<dyn Error>> { fn clone_repo_to_temp(
&self,
repo_url: &str,
proxy: Option<String>,
) -> Result<TempDir, Box<dyn Error>> {
let temp_dir = TempDir::new()?; let temp_dir = TempDir::new()?;
let zip_url = repo_url.to_owned() + "/archive/master.zip"; let zip_url = repo_url.to_owned() + "/archive/master.zip";

View File

@ -1,6 +1,6 @@
use log::info; use log::info;
use std::path::PathBuf;
use std::os::unix::fs::symlink; use std::os::unix::fs::symlink;
use std::path::PathBuf;
const MODULO_APP_BUNDLE_NAME: &str = "Modulo.app"; const MODULO_APP_BUNDLE_NAME: &str = "Modulo.app";
const MODULO_APP_BUNDLE_PLIST_CONTENT: &'static str = include_str!("../../res/mac/modulo.plist"); const MODULO_APP_BUNDLE_PLIST_CONTENT: &'static str = include_str!("../../res/mac/modulo.plist");
@ -11,13 +11,16 @@ pub fn generate_modulo_app_bundle(modulo_path: &str) -> Result<PathBuf, std::io:
let modulo_path: String = if !modulo_pathbuf.exists() { let modulo_path: String = if !modulo_pathbuf.exists() {
// If modulo was taken from the PATH, we need to calculate the absolute path // If modulo was taken from the PATH, we need to calculate the absolute path
// To do so, we use the `which` command // To do so, we use the `which` command
let output = std::process::Command::new("which").arg("modulo").output().expect("unable to call 'which' command to determine modulo's full path"); let output = std::process::Command::new("which")
.arg("modulo")
.output()
.expect("unable to call 'which' command to determine modulo's full path");
let path = String::from_utf8_lossy(output.stdout.as_slice()); let path = String::from_utf8_lossy(output.stdout.as_slice());
let path = path.trim(); let path = path.trim();
info!("Detected modulo's full path: {:?}", &path); info!("Detected modulo's full path: {:?}", &path);
path.to_string() path.to_string()
}else{ } else {
modulo_path.to_owned() modulo_path.to_owned()
}; };

View File

@ -54,8 +54,12 @@ impl ModuloManager {
// See issue: https://github.com/federico-terzi/espanso/issues/430 // See issue: https://github.com/federico-terzi/espanso/issues/430
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
{ {
modulo_path = Some(mac::generate_modulo_app_bundle(path).expect("unable to generate modulo app stub") modulo_path = Some(
.to_string_lossy().to_string()); mac::generate_modulo_app_bundle(path)
.expect("unable to generate modulo app stub")
.to_string_lossy()
.to_string(),
);
} }
} }