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

@ -89,4 +89,4 @@ pub fn wait_for_modifiers_release() -> bool {
std::thread::sleep(std::time::Duration::from_millis(100));
}
false
}
}

View File

@ -98,8 +98,13 @@ fn main() {
.required(false)
.default_value("hub"),
)
.arg(Arg::with_name("proxy").help("Use a proxy, should be used as --proxy=https://proxy:1234")
.required(false).long("proxy").takes_value(true));
.arg(
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")
.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);
Some(proxy.to_string())
}
None => {None}
None => None,
};
let package_resolver = Box::new(ZipPackageResolver::new());

View File

@ -49,7 +49,11 @@ pub trait PackageManager {
}
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)]

View File

@ -13,7 +13,11 @@ impl 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 zip_url = repo_url.to_owned() + "/archive/master.zip";

View File

@ -1,6 +1,6 @@
use log::info;
use std::path::PathBuf;
use std::os::unix::fs::symlink;
use std::path::PathBuf;
const MODULO_APP_BUNDLE_NAME: &str = "Modulo.app";
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() {
// If modulo was taken from the PATH, we need to calculate the absolute path
// 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 = path.trim();
info!("Detected modulo's full path: {:?}", &path);
path.to_string()
}else{
} else {
modulo_path.to_owned()
};
@ -38,7 +41,7 @@ pub fn generate_modulo_app_bundle(modulo_path: &str) -> Result<PathBuf, std::io:
let macos_dir = contents_dir.join("MacOS");
std::fs::create_dir(&macos_dir)?;
let resources_dir = contents_dir.join("Resources");
std::fs::create_dir(&resources_dir)?;
@ -58,4 +61,4 @@ pub fn generate_modulo_app_bundle(modulo_path: &str) -> Result<PathBuf, std::io:
info!("Created Modulo APP stub at: {:?}", &target_link);
Ok(target_link)
}
}

View File

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