diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..af2d1ef --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ + +### 0.2.0 (2018-12-22) + + +#### Features + +* Supported Albert launcher + + + +### 0.1.0 (2016-12-11) + +#### Features + +* Supported Alfred launcher +* Supported Hain launcher diff --git a/Cargo.lock b/Cargo.lock index 84db3ac..dcc3696 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,7 +8,7 @@ name = "aho-corasick" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -35,7 +35,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "arrayvec" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -46,30 +46,36 @@ name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "autocfg" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "backtrace" -version = "0.3.9" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "backtrace-sys" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -82,7 +88,7 @@ name = "blake2-rfc" version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -111,7 +117,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bzip2-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -119,8 +125,8 @@ name = "bzip2-sys" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -131,10 +137,10 @@ dependencies = [ "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_env_logger 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)", "zip 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -142,7 +148,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.25" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -157,7 +163,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -205,7 +211,7 @@ name = "dirs" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -227,7 +233,7 @@ name = "error-chain" version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -235,7 +241,7 @@ name = "failure" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -246,7 +252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -284,7 +290,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "heck" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -325,7 +331,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.44" +version = "0.2.45" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -358,11 +364,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memchr" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -391,7 +397,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pest" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -399,32 +405,32 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pest 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_generator 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pest_generator" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pest 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_meta 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pest_meta 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pest_meta" -version = "2.0.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pest 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -471,13 +477,13 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -485,7 +491,7 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -496,7 +502,7 @@ dependencies = [ "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -505,7 +511,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -529,7 +535,7 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -544,17 +550,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_derive" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -564,7 +570,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -593,37 +599,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "0.14.9" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "syn" -version = "0.15.22" +version = "0.15.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -638,7 +634,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -661,10 +657,10 @@ dependencies = [ "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pest 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "pest_derive 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", "slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "unic-segment 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -684,8 +680,8 @@ name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -707,11 +703,11 @@ dependencies = [ [[package]] name = "time" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -872,7 +868,7 @@ dependencies = [ "crc32fast 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libflate 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] @@ -881,10 +877,11 @@ dependencies = [ "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" -"checksum arrayvec 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f405cc4c21cd8b784f6c8fc2adf9bc00f59558f0049b5ec21517f875963040cc" +"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71" "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" -"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" +"checksum autocfg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4e5f34df7a019573fb8bdc7e24a2bfebe51a2a1d6bfdbaeccedb3c41fc574727" +"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" +"checksum backtrace-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3fcce89e5ad5c8949caa9434501f7b55415b3e7ad5270cb88c75a8d35e8f1279" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab" @@ -892,7 +889,7 @@ dependencies = [ "checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d" "checksum bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b" "checksum bzip2-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6584aa36f5ad4c9247f5323b0a42f37802b37a836f0ad87084d7a33961abe25f" -"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" +"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" @@ -910,51 +907,50 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum generic-array 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef25c5683767570c2bbd7deba372926a55eaae9982d7726ee2a1050239d45b9d" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" -"checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" +"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1" -"checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" +"checksum libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2857ec59fadc0773853c664d2d18e7198e83883e7060b63c924cb077bd5c74" "checksum libflate 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "bff3ac7d6f23730d3b533c35ed75eef638167634476a499feef16c428d74b57b" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum maplit 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" -"checksum memchr 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0a3eb002f0535929f1199681417029ebea04aadc0c7a4224b46be99c7f5d6a16" +"checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum pest 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a677051ad923732bb5c70f2d45f8985a96e3eee2e2bff86697e3b11b0c3fcfde" -"checksum pest_derive 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b76f477146419bc539a63f4ef40e902166cb43b3e51cecc71d9136fd12c567e7" -"checksum pest_generator 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ebee4e9680be4fd162e6f3394ae4192a6b60b1e4d17d845e631f0c68d1a3386" -"checksum pest_meta 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1f6d5f6f0e6082578c86af197d780dc38328e3f768cec06aac9bc46d714e8221" +"checksum pest 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "54f0c72a98d8ab3c99560bfd16df8059cc10e1f9a8e83e6e3b97718dd766e9c3" +"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +"checksum pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646" +"checksum pest_meta 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5a3492a4ed208ffc247adcdcc7ba2a95be3104f58877d0d02f0df39bf3efb5e" "checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd" "checksum pretty_env_logger 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8d1e63042e889b85228620629b51c011d380eed2c7e0015f8a644def280c28" "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" -"checksum redox_syscall 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "679da7508e9a6390aeaf7fbd02a800fdc64b73fe2204dd2c8ae66d22d9d5ad5d" +"checksum redox_syscall 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "a84bcd297b87a545980a2d25a0beb72a1f490c31f0a9fde52fca35bfbb1ceb70" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum redox_users 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "214a97e49be64fd2c86f568dd0cb2c757d2cc53de95b273b6ad0a1c908482f26" "checksum regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37e7cbbd370869ce2e8dff25c7018702d10b21a20ef7135316f8daecd6c25b7f" "checksum regex-syntax 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4e47a2ed29da7a9e1960e1639e7a982e6edc6d49be308a3b02daf511504a16d1" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" +"checksum rustc-demangle 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "01b90379b8664dd83460d59bdc5dd1fd3172b8913788db483ed1325171eab2f7" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" -"checksum serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "15c141fc7027dd265a47c090bf864cf62b42c4d228bbcf4e51a0c9e2b0d3f7ef" -"checksum serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)" = "225de307c6302bec3898c51ca302fc94a7a1697ef0845fcee6448f33c032249c" +"checksum serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "6fa52f19aee12441d5ad11c9a00459122bd8f98707cadf9778c540674f1935b6" +"checksum serde_derive 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "96a7f9496ac65a2db5929afa087b54f8fc5008dcfbe48a8874ed20049b0d6154" "checksum serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)" = "c37ccd6be3ed1fdf419ee848f7c758eb31b054d7cd3ae3600e3bae0adf569811" "checksum sha-1 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "51b9d1f3b5de8a167ab06834a7c883bd197f2191e1dda1a22d9ccfeedbf9aded" "checksum slug 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum structopt 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "41c4a2479a078509940d82773d90ff824a8c89533ab3b59cd3ce8b0c0e369c02" -"checksum structopt-derive 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5352090cfae7a2c85e1a31146268b53396106c88ca5d6ccee2e3fae83b6e35c2" -"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7" +"checksum structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "670ad348dc73012fcf78c71f06f9d942232cdd4c859d4b6975e27836c3efc0c3" +"checksum structopt-derive 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ef98172b1a00b0bec738508d3726540edcbd186d50dfd326f2b1febbb3559f04" +"checksum syn 0.15.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9545a6a093a3f0bd59adb472700acc08cad3776f860f16a897dfce8c88721cbc" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tera 0.11.20 (registry+https://github.com/rust-lang/crates.io-index)" = "4b505279e19d8f7d24b1a9dc58327c9c36174b1a2c7ebdeac70792d017cb64f3" @@ -962,7 +958,7 @@ dependencies = [ "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" +"checksum time 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "847da467bf0db05882a9e2375934a8a55cffdc9db0d128af1518200260ba1f6c" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-trie 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "71a9c5b1fe77426cf144cc30e49e955270f5086e31a6441dfa8b32efc09b9d77" "checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" diff --git a/Makefile b/Makefile index 6a8b2ba..847e2d9 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ CARGO_VERSION := stable CARGO_OPTIONS := CARGO_SUB_OPTIONS := CARGO_COMMAND := cargo +$(CARGO_VERSION) $(CARGO_OPTIONS) -APP_ARGS := launcher albert +APP_ARGS := launcher alfred # Environment #=============================================================== diff --git a/README.md b/README.md index cd4b160..273c805 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,34 @@ If the cargo project is a binary crates, this tool can register the binary in th - [Albert](https://albertlauncher.github.io/docs/extensions/python/) - Register as Python extension -## TODO -- [ ] cargo workspace(Only single binary crates) -- [ ] customize launcher scripts +## Demo +Alfred: +![Preview](https://camo.qiitausercontent.com/4f154fa67b49cd18cc69188d1871e8dba9603e9a/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f3535353449473062524a68327830357a52492f67697068792e676966) + + +## Installation +cargo-launcher can be installed with cargo install: + +``` shell +$ cargo install cargo-launcher +``` + +To upgrade: + +``` shell +$ cargo install --force cargo-launcher +``` + +The resulting binary should then be in $HOME/.cargo/bin. + +Or download binary from [gthub release page](https://github.com/watawuwu/cargo-launcher/releases). + ## Usage ### Common -- Install CLI binary +- Install target CLI binary(not cargo-launcher) ``` shell $ cd {your binary crates project} diff --git a/src/albert.rs b/src/albert.rs index 3037274..76a095f 100644 --- a/src/albert.rs +++ b/src/albert.rs @@ -1,106 +1,109 @@ -#[cfg(target_os = "linux")] use failure::*; -#[cfg(target_os = "linux")] use log::*; -#[cfg(target_os = "linux")] use std::fs; -#[cfg(target_os = "linux")] use std::path::PathBuf; use crate::cargo::CargoConfig; use crate::error::Result; -#[cfg(target_os = "linux")] use crate::fs::write_file; -use crate::launcher::LauncherConfig; -#[cfg(target_os = "linux")] +use crate::launcher::{LauncherConfig, LauncherLike}; use crate::tpl::{self, Param}; -#[cfg(target_os = "linux")] const MODULE_TEMPLATE: &[u8] = include_bytes!("asset/albert/__init__.py"); -#[cfg(target_os = "linux")] -pub fn install(cargo_conf: &CargoConfig, launcher_conf: &LauncherConfig) -> Result<()> { - let workflow_path = make(cargo_conf, launcher_conf)?; - copy(cargo_conf, workflow_path)?; - Ok(()) +pub struct Albert<'a> { + cargo_config: &'a CargoConfig, + launcher_config: &'a LauncherConfig, } -#[cfg(target_os = "linux")] -fn make(cargo_conf: &CargoConfig, launcher_conf: &LauncherConfig) -> Result> { - let module = module_path(&launcher_conf.work_dir)?; - write_file(&module, module_bin(cargo_conf)?.as_bytes())?; +impl<'a> Albert<'a> { + pub fn new(cargo_config: &'a CargoConfig, launcher_config: &'a LauncherConfig) -> Albert<'a> { + Albert { + cargo_config, + launcher_config, + } + } - let icon = icon_path(&launcher_conf.work_dir)?; - write_file(&icon, &launcher_conf.icon(cargo_conf)?[..])?; + fn application_config(&self) -> Result { + let mut path = dirs::home_dir().ok_or_else(|| err_msg("Notfound home dir"))?; + path.push(".local/share/albert/org.albert.extension.python/modules"); - Ok(vec![module, icon]) -} + path.push(self.cargo_config.name()); + Ok(path) + } -#[cfg(target_os = "linux")] -fn module_bin(config: &CargoConfig) -> Result { - let mut params = Param::new(); - params.insert("prettyname", config.name()); - params.insert("version", config.version()); - params.insert("trigger", config.name()); - params.insert("author", &config.author()); + // todo string to bytes + fn module_bin(&self) -> Result { + let conf = self.cargo_config; + let mut params = Param::new(); + params.insert("prettyname", conf.name()); + params.insert("version", conf.version()); + params.insert("trigger", conf.name()); + params.insert("author", &conf.author()); - let tpl = String::from_utf8_lossy(MODULE_TEMPLATE).into_owned(); - let contents = tpl::render(&tpl, ¶ms)?; + let tpl = String::from_utf8_lossy(MODULE_TEMPLATE).into_owned(); + let contents = tpl::render(&tpl, ¶ms)?; - Ok(contents) -} + Ok(contents) + } + + fn module_path(&self) -> PathBuf { + let mut buf = self.launcher_config.work_dir.clone(); + buf.push("__init__.py"); + buf + } -#[cfg(target_os = "linux")] -fn copy(conf: &CargoConfig, paths: Vec) -> Result<()> { - let sink_dir = application_config(conf)?; - fs::create_dir_all(&sink_dir)?; - for path in paths { - debug!("path: {:?}", &path); - debug!("sink: {:?}", &sink_dir); - let name = path.file_name().ok_or_else(|| err_msg("Not file type"))?; - let mut sink = sink_dir.clone(); - sink.push(name); - fs::copy(&path, sink)?; + fn icon_path(&self) -> PathBuf { + let mut buf = self.launcher_config.work_dir.clone(); + buf.push("icon.png"); + buf } - show_help(&sink_dir); - Ok(()) + fn icon(&self) -> Result> { + self.launcher_config.icon(self.cargo_config) + } } -#[cfg(target_os = "linux")] -fn show_help(path: &PathBuf) { - let msg = r#" -Install completed!! -Please check the checkbox of the python extension list and activate the setting. +impl<'a> LauncherLike for Albert<'a> { + fn before_check(&self) -> Result<()> { + if cfg!(not(target_os = "linux")) { + bail!("Albert supported only linux") + } + Ok(()) + } -Installed path: "#; - println!("{}{}", msg, path.to_string_lossy()); -} + fn gen(&self) -> Result> { + let module = self.module_path(); + write_file(&module, self.module_bin()?.as_bytes())?; -#[cfg(target_os = "linux")] -fn application_config(cargo_conf: &CargoConfig) -> Result { - let mut path = dirs::home_dir().ok_or_else(|| err_msg("Notfound home dir"))?; - path.push(".local/share/albert/org.albert.extension.python/modules"); - path.push(cargo_conf.name()); - Ok(path) -} + let icon = self.icon_path(); + write_file(&icon, &self.icon()?[..])?; -#[cfg(target_os = "linux")] -fn module_path(dir: &PathBuf) -> Result { - path(dir, "__init__.py") -} + Ok(vec![module, icon]) + } -#[cfg(target_os = "linux")] -fn icon_path(dir: &PathBuf) -> Result { - path(dir, "icon.png") -} + fn deploy(&self, paths: Vec) -> Result<()> { + let sink_dir = self.application_config()?; + fs::create_dir_all(&sink_dir)?; + for path in paths { + debug!("path: {:?}", &path); + debug!("sink: {:?}", &sink_dir); + let name = path.file_name().ok_or_else(|| err_msg("Not file type"))?; + let mut sink = sink_dir.clone(); + sink.push(name); + fs::copy(&path, sink)?; + } + Ok(()) + } -#[cfg(target_os = "linux")] -fn path(dir: &PathBuf, name: &str) -> Result { - let dir_s = dir.to_str().ok_or_else(|| err_msg("NotFound dir path"))?; - Ok(PathBuf::from(format!("{}/{}", dir_s, name))) -} + fn show_help(&self) -> Result<()> { + let msg = r#" +Install completed!! +Please check the checkbox of the python extension list and activate the setting. -#[cfg(not(target_os = "linux"))] -pub fn install(_cargo_conf: &CargoConfig, _launcher_conf: &LauncherConfig) -> Result<()> { - failure::bail!("Albert supported only linux") +Installed path: "#; + + let path = self.application_config()?; + println!("{}{}", msg, path.to_string_lossy()); + Ok(()) + } } diff --git a/src/alfred.rs b/src/alfred.rs index 7643cc0..4c8e2ba 100644 --- a/src/alfred.rs +++ b/src/alfred.rs @@ -1,82 +1,99 @@ -#[cfg(target_os = "macos")] +use failure::bail; use std::fs::File; -#[cfg(target_os = "macos")] use std::io::Write; -#[cfg(target_os = "macos")] -use std::path::{Path, PathBuf}; -#[cfg(target_os = "macos")] +use std::path::PathBuf; use zip::write::{FileOptions, ZipWriter}; use crate::cargo::CargoConfig; -#[cfg(target_os = "macos")] use crate::core::*; use crate::error::Result; -use crate::launcher::LauncherConfig; -#[cfg(target_os = "macos")] +use crate::launcher::{LauncherConfig, LauncherLike}; use crate::tpl::{self, Param}; -#[cfg(target_os = "macos")] const INFO_PLIST: &[u8] = include_bytes!("asset/alfred/info.plist"); -#[cfg(target_os = "macos")] const EXTENSION: &str = "alfredworkflow"; -#[cfg(target_os = "macos")] -pub fn install(cargo_conf: &CargoConfig, launcher_conf: &LauncherConfig) -> Result<()> { - let workflow_path = make(cargo_conf, launcher_conf)?; - open(&[workflow_path.as_ref()])?; - Ok(()) +pub struct Alfred<'a> { + cargo_config: &'a CargoConfig, + launcher_config: &'a LauncherConfig, } -#[cfg(target_os = "macos")] -fn make(cargo_conf: &CargoConfig, launcher_conf: &LauncherConfig) -> Result { - let workflow_path = workflow_path(cargo_conf.name(), &launcher_conf.work_dir); - let zip = File::create(&workflow_path)?; - let mut writer = ZipWriter::new(zip); - let options = FileOptions::default(); +impl<'a> Alfred<'a> { + pub fn new(cargo_config: &'a CargoConfig, launcher_config: &'a LauncherConfig) -> Alfred<'a> { + Alfred { + cargo_config, + launcher_config, + } + } - writer.start_file("info.plist", options)?; - let info_plist = info_plist(&cargo_conf)?; - writer.write_all(info_plist.as_bytes())?; + fn workflow_path(&self) -> PathBuf { + let name = self.cargo_config.name(); + let dir = &self.launcher_config.work_dir; + let path = dir.to_str().unwrap_or(""); + PathBuf::from(format!("{}/{}.{}", path, name, EXTENSION)) + } - writer.start_file("icon.png", options)?; - writer.write_all(&launcher_conf.icon(cargo_conf)?)?; + fn info_plist(&self) -> Result { + let conf = self.cargo_config; + let mut params = Param::new(); + params.insert("name", conf.name()); + params.insert("description", conf.description()); + params.insert("createdby", &conf.author()); + params.insert("buildid", &conf.build_id()); - writer.finish()?; - Ok(workflow_path) -} + let tpl = String::from_utf8_lossy(INFO_PLIST).into_owned(); + let info_plist = tpl::render(&tpl, ¶ms)?; -// TODO Install workflow via CUI or apple script. -#[cfg(target_os = "macos")] -fn open(paths: &[&Path]) -> Result<()> { - let args = paths - .iter() - .map(|f| f.to_str().unwrap_or("")) - .collect::>(); - let _ = command("open", Some(args))?; - Ok(()) -} + Ok(info_plist) + } -#[cfg(target_os = "macos")] -fn workflow_path(file_name: &str, dir_path: &PathBuf) -> PathBuf { - let path = dir_path.to_str().unwrap_or(""); - PathBuf::from(format!("{}/{}.{}", path, file_name, EXTENSION)) + fn icon(&self) -> Result> { + self.launcher_config.icon(self.cargo_config) + } } -#[cfg(target_os = "macos")] -fn info_plist(config: &CargoConfig) -> Result { - let mut params = Param::new(); - params.insert("name", config.name()); - params.insert("description", config.description()); - params.insert("createdby", &config.author()); - params.insert("buildid", &config.build_id()); +impl<'a> LauncherLike for Alfred<'a> { + fn before_check(&self) -> Result<()> { + if cfg!(not(target_os = "macos")) { + bail!("Alfred supported only macOS") + } + Ok(()) + } - let tpl = String::from_utf8_lossy(INFO_PLIST).into_owned(); - let info_plist = tpl::render(&tpl, ¶ms)?; + fn gen(&self) -> Result> { + let workflow_path = self.workflow_path(); + let zip = File::create(&workflow_path)?; + let mut writer = ZipWriter::new(zip); + let options = FileOptions::default(); - Ok(info_plist) -} + writer.start_file("info.plist", options)?; + let info_plist = self.info_plist()?; + writer.write_all(info_plist.as_bytes())?; + + writer.start_file("icon.png", options)?; + writer.write_all(&self.icon()?)?; + + writer.finish()?; + Ok(vec![workflow_path]) + } + + fn deploy(&self, paths: Vec) -> Result<()> { + let args = paths + .iter() + .map(|f| f.to_str().unwrap_or("")) + .collect::>(); + let _ = command("open", Some(args))?; + Ok(()) + } + + fn show_help(&self) -> Result<()> { + let msg = r#" +Install completed!! -#[cfg(not(target_os = "macos"))] -pub fn install(_cargo_conf: &CargoConfig, _launcher_conf: &LauncherConfig) -> Result<()> { - failure::bail!("Alfred supported only macOS") +Note: +Powerpack is necessary to use Alfred workflow. +"#; + println!("{}", msg); + Ok(()) + } } diff --git a/src/asset/alfred/info.plist b/src/asset/alfred/info.plist index 468e9f8..d83af54 100644 --- a/src/asset/alfred/info.plist +++ b/src/asset/alfred/info.plist @@ -89,7 +89,7 @@ if [[ -z $query ]] then result=$({{name}}) else - result=$({{name}} "$query") + result=$({{name}} $query) fi code=$? diff --git a/src/asset/hain/index.js b/src/asset/hain/index.js index c1f2e1e..61bc33c 100644 --- a/src/asset/hain/index.js +++ b/src/asset/hain/index.js @@ -15,8 +15,9 @@ module.exports = (pluginContext) => { function search(query, res) { logger.log('query: ' + query); logger.log('res: ' + res); - exec(`{{name}} "${query}"`, (err, stdout, stderr) => { + exec(`{{name}} ${query}`, (err, stdout, stderr) => { if (err) { + // todo show error logger.log(`error: ${err}`); } logger.log(`stdout: ${stdout}`); diff --git a/src/cargo.rs b/src/cargo.rs index b80d094..71f7133 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -31,7 +31,6 @@ impl CargoConfig { .unwrap_or_else(|| String::from("")) } - #[cfg(target_os = "macos")] pub fn build_id(&self) -> String { format!("{}-{}", self.name(), hash(self.name())) } diff --git a/src/core.rs b/src/core.rs index e3a2dae..f7f20dd 100644 --- a/src/core.rs +++ b/src/core.rs @@ -1,8 +1,6 @@ use crate::error::Result; -#[cfg(target_os = "macos")] use std::collections::hash_map::DefaultHasher; use std::ffi::OsStr; -#[cfg(target_os = "macos")] use std::hash::Hasher; use std::process::Command; @@ -14,7 +12,6 @@ pub fn command>(program: P, maybe_args: Option>) -> Resul Ok(result) } -#[cfg(target_os = "macos")] pub fn hash(input: &str) -> u64 { let mut hasher = DefaultHasher::new(); hasher.write(input.as_bytes()); diff --git a/src/hain.rs b/src/hain.rs index f1dec99..85e245d 100644 --- a/src/hain.rs +++ b/src/hain.rs @@ -7,137 +7,155 @@ use std::path::PathBuf; use crate::cargo::CargoConfig; use crate::error::Result; use crate::fs::write_file; -use crate::launcher::LauncherConfig; +use crate::launcher::{LauncherConfig, LauncherLike}; use crate::tpl::{self, Param}; const INDEX_JS_BIN: &[u8] = include_bytes!("asset/hain/index.js"); const PACKAGE_JSON_BIN: &[u8] = include_bytes!("asset/hain/package.json"); -pub fn install(cargo_conf: &CargoConfig, launch_conf: &LauncherConfig) -> Result<()> { - let paths = make(cargo_conf, launch_conf)?; - copy(cargo_conf, paths)?; - Ok(()) +pub struct Hain<'a> { + cargo_config: &'a CargoConfig, + launcher_config: &'a LauncherConfig, } -pub fn make(cargo_conf: &CargoConfig, launch_conf: &LauncherConfig) -> Result> { - let index = index_js_path(&launch_conf.work_dir)?; - write_file(&index, index_js(cargo_conf)?.as_bytes())?; +impl<'a> Hain<'a> { + pub fn new(cargo_config: &'a CargoConfig, launcher_config: &'a LauncherConfig) -> Hain<'a> { + Hain { + cargo_config, + launcher_config, + } + } - let package = package_json_path(&launch_conf.work_dir)?; - write_file(&package, package_json(cargo_conf)?.as_bytes())?; + #[cfg(target_os = "macos")] + fn application_config(&self) -> Result { + let mut path = dirs::home_dir().ok_or_else(|| err_msg("Notfound home dir"))?; + path.push("Library"); + path.push("Application Support"); + path.push("hain-user"); + path.push("devplugins"); + path.push(self.plugin_name()); + Ok(path) + } - let icon = icon_path(&launch_conf.work_dir)?; - write_file(&icon, &launch_conf.icon(cargo_conf)?[..])?; + #[cfg(target_os = "linux")] + fn application_config(&self) -> Result { + let mut path = dirs::config_dir().ok_or_else(|| err_msg("Notfound home dir"))?; + if let Some(home) = std::env::var_os("XDG_CONFIG_HOME") { + path = PathBuf::from(home); + }; + path.push("hain-user/devplugins"); + path.push(self.plugin_name()); + Ok(path) + } - Ok(vec![index, package, icon]) -} + #[cfg(target_os = "windows")] + fn application_config(&self) -> Result { + let local = std::env::var_os("LOCALAPPDATA"); + let user = std::env::var_os("USERPROFILE"); + + let mut path = match (local, user) { + (Some(l), _) => PathBuf::from(l), + (None, Some(u)) => PathBuf::from(format!( + "{}/Local Settings/Application Data", + u.to_str().unwrap() + )), + _ => bail!("Notfound home dir"), + }; + path.push("hain-user/devplugins"); + path.push(self.plugin_name()); + Ok(path) + } -fn copy(conf: &CargoConfig, paths: Vec) -> Result<()> { - let sink_dir = application_config(conf)?; - fs::create_dir_all(&sink_dir)?; - for path in paths { - debug!("path: {:?}", &path); - debug!("sink: {:?}", &sink_dir); - let name = path.file_name().ok_or_else(|| err_msg("Not file type"))?; - let mut sink = sink_dir.clone(); - sink.push(name); - fs::copy(&path, sink)?; + fn index_js_path(&self) -> PathBuf { + let mut buf = self.launcher_config.work_dir.clone(); + buf.push("index.js"); + buf } - show_help(&sink_dir); - Ok(()) -} + fn package_json_path(&self) -> PathBuf { + let mut buf = self.launcher_config.work_dir.clone(); + buf.push("package.json"); + buf + } -fn show_help(path: &PathBuf) { - let msg = r#" -Install completed!! -Restart of the hain is required. + fn icon_path(&self) -> PathBuf { + let mut buf = self.launcher_config.work_dir.clone(); + buf.push("icon.png"); + buf + } -Installed path: "#; - println!("{}{}", msg, path.to_string_lossy()); -} + fn index_js(&self) -> Result { + let mut params = Param::new(); + params.insert("name", self.cargo_config.name()); + let tpl = String::from_utf8_lossy(INDEX_JS_BIN).into_owned(); + let contents = tpl::render(&tpl, ¶ms)?; -// hain config dir spec -// https://github.com/LinusU/node-application-config-path/blob/master/index.js -#[cfg(target_os = "macos")] -fn application_config(cargo_conf: &CargoConfig) -> Result { - let mut path = dirs::home_dir().ok_or_else(|| err_msg("Notfound home dir"))?; - path.push("Library"); - path.push("Application Support"); - path.push("hain-user"); - path.push("devplugins"); - path.push(plugin_name(cargo_conf.name())); - Ok(path) -} + Ok(contents) + } -#[cfg(target_os = "linux")] -fn application_config(cargo_conf: &CargoConfig) -> Result { - let mut path = dirs::config_dir().ok_or_else(|| err_msg("Notfound home dir"))?; - if let Some(home) = std::env::var_os("XDG_CONFIG_HOME") { - path = PathBuf::from(home); - }; - path.push("hain-user/devplugins"); - path.push(plugin_name(cargo_conf.name())); - Ok(path) -} + fn package_json(&self) -> Result { + let conf = self.cargo_config; + let mut params = Param::new(); + params.insert("name", conf.name()); + params.insert("version", conf.version()); + params.insert("description", conf.description()); + params.insert("author", &conf.author()); -#[cfg(target_os = "windows")] -fn application_config(cargo_conf: &CargoConfig) -> Result { - let local = std::env::var_os("LOCALAPPDATA"); - let user = std::env::var_os("USERPROFILE"); - - let mut path = match (local, user) { - (Some(l), _) => PathBuf::from(l), - (None, Some(u)) => PathBuf::from(format!( - "{}/Local Settings/Application Data", - u.to_str().unwrap() - )), - _ => bail!("Notfound home dir"), - }; - path.push("hain-user/devplugins"); - path.push(plugin_name(cargo_conf.name())); - Ok(path) -} + let tpl = String::from_utf8_lossy(PACKAGE_JSON_BIN).into_owned(); + let contents = tpl::render(&tpl, ¶ms)?; -fn index_js_path(dir: &PathBuf) -> Result { - path(dir, "index.js") -} + Ok(contents) + } -fn package_json_path(dir: &PathBuf) -> Result { - path(dir, "package.json") -} + fn plugin_name(&self) -> String { + format!("hain-plugin-{}", self.cargo_config.name()) + } -fn icon_path(dir: &PathBuf) -> Result { - path(dir, "icon.png") + fn icon(&self) -> Result> { + self.launcher_config.icon(self.cargo_config) + } } -fn path(dir: &PathBuf, name: &str) -> Result { - let dir_s = dir.to_str().ok_or_else(|| err_msg("NotFound dir path"))?; - Ok(PathBuf::from(format!("{}/{}", dir_s, name))) -} +impl<'a> LauncherLike for Hain<'a> { + fn before_check(&self) -> Result<()> { + Ok(()) + } -fn index_js(config: &CargoConfig) -> Result { - let mut params = Param::new(); - params.insert("name", config.name()); - let tpl = String::from_utf8_lossy(INDEX_JS_BIN).into_owned(); - let contents = tpl::render(&tpl, ¶ms)?; + fn gen(&self) -> Result> { + let index = self.index_js_path(); + write_file(&index, self.index_js()?.as_bytes())?; - Ok(contents) -} + let package = self.package_json_path(); + write_file(&package, self.package_json()?.as_bytes())?; -fn package_json(config: &CargoConfig) -> Result { - let mut params = Param::new(); - params.insert("name", config.name()); - params.insert("version", config.version()); - params.insert("description", config.description()); - params.insert("author", &config.author()); + let icon = self.icon_path(); + write_file(&icon, &self.icon()?[..])?; - let tpl = String::from_utf8_lossy(PACKAGE_JSON_BIN).into_owned(); - let contents = tpl::render(&tpl, ¶ms)?; + Ok(vec![index, package, icon]) + } - Ok(contents) -} + fn deploy(&self, paths: Vec) -> Result<()> { + let sink_dir = self.application_config()?; + fs::create_dir_all(&sink_dir)?; + for path in paths { + debug!("path: {:?}", &path); + debug!("sink: {:?}", &sink_dir); + let name = path.file_name().ok_or_else(|| err_msg("Not file type"))?; + let mut sink = sink_dir.clone(); + sink.push(name); + fs::copy(&path, sink)?; + } + Ok(()) + } + + fn show_help(&self) -> Result<()> { + let msg = r#" +Install completed!! +Restart of the hain is required. -fn plugin_name(name: &str) -> String { - format!("hain-plugin-{}", name) +Installed path: "#; + let path = self.application_config()?; + println!("{}{}", msg, path.to_string_lossy()); + Ok(()) + } } diff --git a/src/launcher.rs b/src/launcher.rs index 75481d5..fb136ee 100644 --- a/src/launcher.rs +++ b/src/launcher.rs @@ -2,13 +2,13 @@ use pretty_env_logger; use std::path::PathBuf; use structopt::clap::*; -use crate::albert; -use crate::alfred; +use crate::albert::Albert; +use crate::alfred::Alfred; use crate::args::Args; use crate::cargo::CargoConfig; use crate::error::Result; use crate::fs::*; -use crate::hain; +use crate::hain::Hain; // @FIXME from metadata and rel2abs const WORK_PATH: &str = "target/launcher"; @@ -22,6 +22,19 @@ arg_enum! { Albert, } } +impl Launcher { + fn instance<'a>( + &self, + cargo_config: &'a CargoConfig, + launcher_config: &'a LauncherConfig, + ) -> Box { + match *self { + Launcher::Alfred => Box::new(Alfred::new(cargo_config, launcher_config)), + Launcher::Hain => Box::new(Hain::new(cargo_config, launcher_config)), + Launcher::Albert => Box::new(Albert::new(cargo_config, launcher_config)), + } + } +} pub struct LauncherConfig { pub work_dir: PathBuf, @@ -43,16 +56,30 @@ impl LauncherConfig { } } +pub trait LauncherLike { + // TODO Result<()> => Result + fn install(&self) -> Result<()> { + self.before_check()?; + let artifacts = self.gen()?; + self.deploy(artifacts)?; + self.show_help() + } + fn before_check(&self) -> Result<()>; + fn gen(&self) -> Result>; + fn deploy(&self, paths: Vec) -> Result<()>; + + // @TODO return string + fn show_help(&self) -> Result<()>; +} + pub fn launch(args: &Args, cargo_config: &CargoConfig) -> Result<()> { let launcher_config = LauncherConfig { work_dir: PathBuf::from(WORK_PATH), icon_bin: ICON_BIN, }; launcher_config.mk_dir()?; - match args.launcher { - Launcher::Alfred => alfred::install(&cargo_config, &launcher_config)?, - Launcher::Hain => hain::install(&cargo_config, &launcher_config)?, - Launcher::Albert => albert::install(&cargo_config, &launcher_config)?, - } + + let launcher = args.launcher.instance(cargo_config, &launcher_config); + launcher.install()?; Ok(()) }