diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4319260..cd51937 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,11 +41,6 @@ jobs: with: files: target/release/lsi.exe - - name: Get version (Unix) - if: matrix.os != 'windows-latest' - id: version - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} - - name: Get tar name (Unix) if: matrix.os != 'windows-latest' id: tar_name diff --git a/Cargo.lock b/Cargo.lock index 075b556..317e0f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,22 +3,56 @@ version = 3 [[package]] -name = "bitflags" -version = "1.3.2" +name = "addr2line" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] -name = "bstr" -version = "0.2.17" +name = "aho-corasick" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ - "lazy_static", "memchr", - "regex-automata", ] +[[package]] +name = "backtrace" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cc" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" + [[package]] name = "cfg-if" version = "1.0.0" @@ -67,19 +101,45 @@ dependencies = [ ] [[package]] -name = "instant" -version = "0.1.12" +name = "getrandom" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" dependencies = [ "cfg-if", + "libc", + "wasi", ] [[package]] -name = "lazy_static" -version = "1.4.0" +name = "gimli" +version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" + +[[package]] +name = "human-panic" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39f357a500abcbd7c5f967c1d45c8838585b36743823b9d43488f24850534e36" +dependencies = [ + "backtrace", + "os_type", + "serde", + "serde_derive", + "termcolor", + "toml", + "uuid", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] [[package]] name = "libc" @@ -89,11 +149,12 @@ checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" [[package]] name = "ls-interactive" -version = "1.0.3" +version = "1.1.0" dependencies = [ "console", "dialoguer", - "opener", + "human-panic", + "open", ] [[package]] @@ -102,6 +163,24 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "miniz_oxide" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +dependencies = [ + "adler", +] + +[[package]] +name = "object" +version = "0.28.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40bec70ba014595f99f7aa110b84331ffe1ee9aece7fe6f387cc7e3ecda4d456" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.10.0" @@ -109,15 +188,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" [[package]] -name = "opener" -version = "0.5.0" +name = "open" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea3ebcd72a54701f56345f16785a6d3ac2df7e986d273eb4395c0b01db17952" +checksum = "e0524af9508f9b5c4eb41dce095860456727748f63b478d625f119a70e0d764a" dependencies = [ - "bstr", + "pathdiff", "winapi", ] +[[package]] +name = "os_type" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3df761f6470298359f84fcfb60d86db02acc22c251c37265c07a3d1057d2389" +dependencies = [ + "regex", +] + +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + +[[package]] +name = "proc-macro2" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +dependencies = [ + "proc-macro2", +] + [[package]] name = "redox_syscall" version = "0.2.13" @@ -133,15 +245,11 @@ version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ + "aho-corasick", + "memchr", "regex-syntax", ] -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" - [[package]] name = "regex-syntax" version = "0.6.25" @@ -157,6 +265,40 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "serde" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" + +[[package]] +name = "serde_derive" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "tempfile" version = "3.3.0" @@ -171,6 +313,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "terminal_size" version = "0.1.17" @@ -181,12 +332,42 @@ dependencies = [ "winapi", ] +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + [[package]] name = "unicode-width" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +[[package]] +name = "unicode-xid" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "winapi" version = "0.3.9" @@ -203,6 +384,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/Cargo.toml b/Cargo.toml index 5413588..85467a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "ls-interactive" description = "Interactive ls command" authors = ["Araxeus "] -version = "1.0.3" +version = "1.1.0" license = "MIT" edition = "2021" readme = "README.md" @@ -14,7 +14,8 @@ categories = ["command-line-utilities"] [dependencies] dialoguer = "0.10.0" console = "0.15.0" -opener = "0.5.0" +open = "2.1.2" +human-panic = "1.0.3" [[bin]] name = "lsi" diff --git a/README.md b/README.md index 0a7d08f..7298ca4 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,7 @@ Download binaries from [releases page](https://github.com/Araxeus/ls-interactive/releases) and place in PATH -or run: -```bash -curl -LSfs https://japaric.github.io/trust/install.sh | sh -s -- --git Araxeus/ls-interactive -``` +Installation from package managers is coming soon ## How to run it @@ -34,7 +31,7 @@ lsi some_directory ``` ## Build it yourself -(The binaries in release are [automatically](https://github.com/Araxeus/ls-interactive/blob/main/.github/workflows/release.yml) built by github actions) +(The binaries in release are [automatically](https://github.com/Araxeus/ls-interactive/blob/master/.github/workflows/release.yml) built by github actions) install `rust` clone/download the repo diff --git a/src/main.rs b/src/main.rs index 2244b0a..6fca699 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,8 +5,6 @@ use std::fmt; use std::fs; use std::path::Path; -use opener::open; - struct Entry { name: String, path: String, @@ -22,6 +20,7 @@ impl fmt::Display for Entry { } fn main() { + human_panic::setup_panic!(); let args: Vec = env::args().collect(); let path = if args.len() >= 2 { args[1].trim() } else { "." }; @@ -40,7 +39,7 @@ fn open_entry(path: &str) { if res.is_dir || res.is_link { open_entry(&res.path); } else { - open(&res.path).unwrap(); + open::that(&res.path).unwrap(); } } diff --git a/src/simple.rs b/src/simple.rs deleted file mode 100644 index 427095a..0000000 --- a/src/simple.rs +++ /dev/null @@ -1,52 +0,0 @@ -use std::env; -use std::fs; - -fn main() { - let res = selector(); - println!("{:?}", res); - let args: Vec = env::args().collect(); - let path = - if args.len() >= 2 { &args[1].trim() } - else {"."}; - - if let Ok(entries) = fs::read_dir(path) { - for entry in entries { - if let Ok(entry) = entry { - if let Ok(file_type) = entry.file_type() { - let icon = String::from( - if file_type.is_file() {"📄"} - else if file_type.is_dir() {"📁"} - else if file_type.is_symlink() {"🔗"} - else {"❔"} - ); - println!("{} {}", icon, entry.file_name().to_str().unwrap()); - } - } - } - } -} - -use dialoguer::{ - Select, - theme::ColorfulTheme -}; -use console::Term; - -fn select(items: Vec<&str>) -> String { - let selection = Select::with_theme(&ColorfulTheme::default()) - .items(&items) - .default(0) - .interact_on_opt(&Term::stderr()).ok().unwrap(); - - match selection { - Some(index) => format!("User selected item : {}", items[index]), - None => format!("User did not select anything") - } -} - -fn selector() -> String { - let items = vec!["Item 1", "item 2"]; - - select(items) -} -