Fix exit error codes

Also remove cucumber-rust (will try https://github.com/rust-rspec/rspec)

Fixes: https://github.com/sayanarijit/xplr/issues/33
pull/53/head v0.4.2
Arijit Basu 3 years ago committed by Arijit Basu
parent 55e1a6a0fa
commit 49ffd8e1f1

490
Cargo.lock generated

@ -2,24 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "anyhow"
version = "1.0.40"
@ -38,38 +20,6 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "async-stream"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c"
dependencies = [
"async-stream-impl",
"futures-core",
]
[[package]]
name = "async-stream-impl"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "async-trait"
version = "0.1.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36ea56748e10732c49404c153638a15ec3d6211ec5ff35d9bb20e13b93576adf"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "atty"
version = "0.2.14"
@ -161,12 +111,6 @@ version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytes"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
[[package]]
name = "cassowary"
version = "0.3.0"
@ -214,13 +158,9 @@ version = "2.33.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim",
"textwrap 0.11.0",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
@ -357,39 +297,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "cucumber_rust"
version = "0.8.4"
source = "git+https://github.com/bbqsrc/cucumber-rust?branch=main#93bdaaf0b358fd34a682e3b8f6bc0ac75f794e77"
dependencies = [
"async-stream",
"async-trait",
"clap",
"cute_custom_default",
"futures",
"futures-timer",
"gherkin_rust",
"globwalk",
"once_cell",
"pathdiff",
"regex",
"shh",
"termcolor",
"textwrap 0.12.1",
"thiserror",
"tracing",
]
[[package]]
name = "cute_custom_default"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed431abf442833fd62ad7cc527a3833d969155c803f0dcf7f8a68db8adddc4c5"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "digest"
version = "0.8.1"
@ -449,12 +356,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "fsevent"
version = "0.4.0"
@ -490,104 +391,6 @@ version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "futures"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9d5813545e459ad3ca1bff9915e9ad7f1a47dc6a91b627ce321d5863b7dd253"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce79c6a52a299137a6013061e0cf0e688fce5d7f1bc60125f520912fdb29ec25"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
name = "futures-core"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815"
[[package]]
name = "futures-executor"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10f6cb7042eda00f0049b1d2080aa4b93442997ee507eb3828e8bd7577f94c9d"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "365a1a1fb30ea1c03a830fdb2158f5236833ac81fa0ad12fe35b29cddc35cb04"
[[package]]
name = "futures-macro"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b"
dependencies = [
"proc-macro-hack",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "futures-sink"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c5629433c555de3d82861a7a4e3794a4c40040390907cfbfd7143a92a426c23"
[[package]]
name = "futures-task"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc"
[[package]]
name = "futures-timer"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
[[package]]
name = "futures-util"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"proc-macro-hack",
"proc-macro-nested",
"slab",
]
[[package]]
name = "generic-array"
version = "0.12.4"
@ -608,47 +411,6 @@ dependencies = [
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]]
name = "gherkin_rust"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ff71b5e012707c7c18bdb710e07736898aba0451f6ffbd435c892dd993053c"
dependencies = [
"heck",
"peg",
"quote",
"serde",
"serde_json",
"syn",
"textwrap 0.12.1",
"thiserror",
"typed-builder",
]
[[package]]
name = "globset"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a"
dependencies = [
"aho-corasick",
"bstr",
"fnv",
"log",
"regex",
]
[[package]]
name = "globwalk"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc"
dependencies = [
"bitflags",
"ignore",
"walkdir",
]
[[package]]
name = "half"
version = "1.7.1"
@ -669,15 +431,6 @@ dependencies = [
"serde_json",
]
[[package]]
name = "heck"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "hermit-abi"
version = "0.1.18"
@ -687,24 +440,6 @@ dependencies = [
"libc",
]
[[package]]
name = "ignore"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c"
dependencies = [
"crossbeam-utils",
"globset",
"lazy_static",
"log",
"memchr",
"regex",
"same-file",
"thread_local",
"walkdir",
"winapi-util",
]
[[package]]
name = "inotify"
version = "0.7.1"
@ -1003,12 +738,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
[[package]]
name = "once_cell"
version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
[[package]]
name = "oorandom"
version = "11.1.3"
@ -1046,39 +775,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "pathdiff"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877630b3de15c0b64cc52f659345724fbf6bdad9bd9566699fc53688f3c34a34"
[[package]]
name = "peg"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f76678828272f177ac33b7e2ac2e3e73cc6c1cd1e3e387928aa69562fa51367"
dependencies = [
"peg-macros",
"peg-runtime",
]
[[package]]
name = "peg-macros"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "636d60acf97633e48d266d7415a9355d4389cea327a193f87df395d88cd2b14d"
dependencies = [
"peg-runtime",
"proc-macro2",
"quote",
]
[[package]]
name = "peg-runtime"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9555b1514d2d99d78150d3c799d4c357a3e2c2a8062cd108e93a06d9057629c5"
[[package]]
name = "pest"
version = "2.1.3"
@ -1122,18 +818,6 @@ dependencies = [
"sha-1",
]
[[package]]
name = "pin-project-lite"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "plotters"
version = "0.3.0"
@ -1162,18 +846,6 @@ dependencies = [
"plotters-backend",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]]
name = "proc-macro-nested"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
[[package]]
name = "proc-macro2"
version = "1.0.26"
@ -1264,8 +936,6 @@ version = "1.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
@ -1406,16 +1076,6 @@ dependencies = [
"opaque-debug",
]
[[package]]
name = "shh"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5205eb079ac8be8ec77b7470aff4a050610d42c32819deee362ca414c926d3ab"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]]
name = "signal-hook"
version = "0.1.17"
@ -1448,12 +1108,6 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "syn"
version = "1.0.68"
@ -1465,25 +1119,6 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "termcolor"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
dependencies = [
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]]
name = "termion"
version = "1.5.6"
@ -1505,45 +1140,6 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "textwrap"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
dependencies = [
"terminal_size",
"unicode-width",
]
[[package]]
name = "thiserror"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd"
dependencies = [
"once_cell",
]
[[package]]
name = "time"
version = "0.1.44"
@ -1565,69 +1161,6 @@ dependencies = [
"serde_json",
]
[[package]]
name = "tokio"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "134af885d758d645f0f0505c9a8b3f9bf8a348fd822e112ab5248138348f1722"
dependencies = [
"autocfg",
"bytes",
"libc",
"memchr",
"mio 0.7.11",
"num_cpus",
"once_cell",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"tokio-macros",
"winapi 0.3.9",
]
[[package]]
name = "tokio-macros"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing"
version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f"
dependencies = [
"cfg-if 1.0.0",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f"
dependencies = [
"lazy_static",
]
[[package]]
name = "tui"
version = "0.14.0"
@ -1642,17 +1175,6 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "typed-builder"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f85f4270f4f449a3f2c0cf2aecc8415e388a597aeacc7d55fc749c5c968c8533"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "typenum"
version = "1.13.0"
@ -1692,12 +1214,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.3"
@ -1846,13 +1362,12 @@ dependencies = [
[[package]]
name = "xplr"
version = "0.4.1"
version = "0.4.2"
dependencies = [
"anyhow",
"chrono",
"criterion",
"crossterm",
"cucumber_rust",
"dirs",
"handlebars",
"lazy_static",
@ -1861,7 +1376,6 @@ dependencies = [
"serde",
"serde_yaml",
"termion",
"tokio",
"tui",
]

@ -1,6 +1,6 @@
[package]
name = "xplr"
version = "0.4.1" # Update default_config.rs and default.nix
version = "0.4.2" # Update config.yml, config.rs and default.nix
authors = ["Arijit Basu <sayanarijit@gmail.com>"]
edition = "2018"
description = "A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf"
@ -27,13 +27,7 @@ lazy_static = "1.4.0"
[dev-dependencies]
criterion = "0.3"
cucumber_rust = { git = "https://github.com/bbqsrc/cucumber-rust", branch = "main" }
tokio = { version = "1.4.0", features = ["full"] }
[[bench]]
name = "navigation"
harness = false
[[test]]
name = "cucumber"
harness = false # Allows Cucumber to print output instead of libtest

@ -4,9 +4,9 @@ with import <nixpkgs> {};
rustPlatform.buildRustPackage rec {
name = "xplr";
version = "0.4.1";
version = "0.4.2";
src = fetchTarball
("https://github.com/sayanarijit/xplr/archive/refs/tags/v0.4.1.tar.gz");
("https://github.com/sayanarijit/xplr/archive/refs/tags/v0.4.2.tar.gz");
buildInputs = [ cargo ];
checkPhase = "";
cargoSha256 = "0000000000000000000000000000000000000000000000000000";

@ -1,16 +0,0 @@
Feature: Default key bindings
Scenario: xplr exits with debug info when we press '#'
Given xplr is running
When I press "#"
And xplr processes the tasks
Then xplr performs "PrintAppStateAndQuit"
And xplr quits or waits for the next event
Scenario: xplr prints result and quits when I gress 'enter'
Given xplr is running
When I press "enter"
And xplr processes the tasks
Then xplr performs "PrintResultAndQuit"
And xplr quits or waits for the next event

@ -608,6 +608,9 @@ pub enum ExternalMsg {
/// Example: `LogError: satellite crashed`
LogError(String),
/// Quit with returncode zero (success).
Quit,
/// Print selected paths if it's not empty, else, print the focused node's path.
PrintResultAndQuit,
@ -642,6 +645,7 @@ pub enum MsgOut {
Explore,
Refresh,
ClearScreen,
Quit,
PrintResultAndQuit,
PrintAppStateAndQuit,
Debug(String),
@ -922,10 +926,11 @@ impl App {
ExternalMsg::LogInfo(l) => self.log_info(l),
ExternalMsg::LogSuccess(l) => self.log_success(l),
ExternalMsg::LogError(l) => self.log_error(l),
ExternalMsg::Quit => self.quit(),
ExternalMsg::PrintResultAndQuit => self.print_result_and_quit(),
ExternalMsg::PrintAppStateAndQuit => self.print_app_state_and_quit(),
ExternalMsg::Debug(path) => self.debug(path),
ExternalMsg::Terminate => bail!("terminated"),
ExternalMsg::Terminate => bail!(""),
}
}
@ -1323,6 +1328,11 @@ impl App {
Ok(self)
}
fn quit(mut self) -> Result<Self> {
self.msg_out.push_back(MsgOut::Quit);
Ok(self)
}
fn print_result_and_quit(mut self) -> Result<Self> {
self.msg_out.push_back(MsgOut::PrintResultAndQuit);
Ok(self)

@ -559,6 +559,7 @@ impl Config {
pub fn is_compatible(&self) -> Result<bool> {
let result = match self.parsed_version()? {
(0, 4, 2) => true,
(0, 4, 1) => true,
(0, 4, 0) => true,
(_, _, _) => false,
@ -569,7 +570,7 @@ impl Config {
pub fn upgrade_notification(&self) -> Result<Option<&str>> {
let result = match self.parsed_version()? {
(0, 4, 1) => None,
(0, 4, 2) => None,
(_, _, _) => Some("New version available"),
};

@ -1,4 +1,4 @@
version: v0.4.1
version: v0.4.2
general:
show_hidden: false
prompt:
@ -218,7 +218,7 @@ modes:
- SwitchMode: default
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
@ -259,7 +259,7 @@ modes:
- SwitchMode: default
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
@ -300,7 +300,7 @@ modes:
- SwitchMode: default
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
@ -316,7 +316,7 @@ modes:
remaps: {}
on_key:
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
d:
@ -373,7 +373,7 @@ modes:
- SwitchMode: default
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
@ -393,9 +393,7 @@ modes:
k: up
l: right
v: space
q: ctrl-c
tab: ctrl-i
on_key:
'#':
help: null
@ -423,13 +421,12 @@ modes:
messages:
- BashExecSilently: |
echo "ChangeDirectory: ${HOME:?}" >> "${XPLR_PIPE_MSG_IN:?}"
echo "Explore" >> "${XPLR_PIPE_MSG_IN:?}"
G:
help: go to bottom
messages:
- FocusLast
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
ctrl-f:
@ -477,7 +474,6 @@ modes:
help: up
messages:
- FocusPrevious
ctrl-o:
help: last visited path
messages:
@ -487,6 +483,10 @@ modes:
help: next visited path
messages:
- NextVisitedPath
q:
help: quit
messages:
- Quit
on_alphabet: null
on_number:
@ -508,7 +508,7 @@ modes:
remaps: {}
on_key:
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
g:
@ -546,7 +546,7 @@ modes:
messages:
- ResetInputBuffer
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
down:
@ -623,7 +623,7 @@ modes:
- Explore
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
@ -636,9 +636,7 @@ modes:
help: null
extra_help: null
key_bindings:
remaps:
q: ctrl-c
remaps: {}
on_number:
help: go to index
messages:
@ -681,7 +679,7 @@ modes:
- SwitchMode: default
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
@ -704,7 +702,7 @@ modes:
- SetInputBuffer: ''
- Explore
ctrl-c:
help: cancel & quit
help: terminate
messages:
- Terminate
down:

@ -71,7 +71,7 @@ fn call(app: &app::App, cmd: app::Command, silent: bool) -> io::Result<ExitStatu
.status()
}
fn main() -> Result<()> {
fn run() -> Result<Option<String>> {
let (tx_msg_in, rx_msg_in) = mpsc::channel();
let (tx_event_reader, rx_event_reader) = mpsc::channel();
let (tx_pwd_watcher, rx_pwd_watcher) = mpsc::channel();
@ -118,8 +118,7 @@ fn main() -> Result<()> {
.join("\t"),
)?;
let mut result = Ok(());
let mut output = None;
let mut result = Ok(None);
term::enable_raw_mode()?;
let mut stdout = get_tty()?;
@ -140,7 +139,7 @@ fn main() -> Result<()> {
let last_app = app.clone();
let (new_app, new_result) = match app.handle_task(task) {
Ok(a) => (a, Ok(())),
Ok(a) => (a, Ok(None)),
Err(err) => (last_app.clone(), Err(err)),
};
@ -157,14 +156,19 @@ fn main() -> Result<()> {
tx_msg_in.send(task)?;
}
app::MsgOut::Quit => {
result = Ok(None);
break 'outer;
}
app::MsgOut::PrintResultAndQuit => {
output = Some(app.result_str());
result = Ok(Some(app.result_str()));
break 'outer;
}
app::MsgOut::PrintAppStateAndQuit => {
let out = serde_yaml::to_string(&app)?;
output = Some(out);
result = Ok(Some(out));
break 'outer;
}
@ -298,9 +302,19 @@ fn main() -> Result<()> {
fs::remove_dir_all(app.session_path())?;
if let Some(out) = output {
print!("{}", out);
}
result
}
fn main() {
match run() {
Ok(Some(out)) => print!("{}", out),
Ok(None) => {}
Err(err) => {
if !err.to_string().is_empty() {
eprintln!("error: {}", err);
};
std::process::exit(1)
}
}
}

@ -1,54 +0,0 @@
use cucumber_rust::{async_trait, criteria::feature, futures::FutureExt, Cucumber, World};
use std::convert::Infallible;
use std::fs;
use xplr::app;
mod steps;
pub enum MyWorld {
Nothing,
App(app::App),
MsgOutList(Vec<app::MsgOut>),
}
#[async_trait(?Send)]
impl World for MyWorld {
type Error = Infallible;
async fn new() -> Result<Self, Infallible> {
Ok(Self::Nothing)
}
}
#[tokio::main]
async fn main() {
Cucumber::<MyWorld>::new()
// Specifies where our feature files exist
.features(&["./features"])
// Adds the implementation of our steps to the runner
.steps(steps::key_bindings::steps())
// Add some lifecycle functions to manage our database nightmare
.before(feature("Example feature"), |_| {
async move {
fs::create_dir_all("/tmp/xplr_bdd").unwrap();
(1..100).for_each(|i| {
fs::File::create(format!("/tmp/xplr_bdd/{}", i)).unwrap();
})
}
.boxed()
})
.after(feature("Example feature"), |_| {
async move {
fs::create_dir_all("/tmp/xplr_bench").unwrap();
(1..100).for_each(|i| {
fs::remove_file(format!("/tmp/xplr_bdd/{}", i)).unwrap();
})
}
.boxed()
})
// Parses the command line arguments if passed
.cli()
// Runs the Cucumber tests and then exists
.run_and_exit()
.await
}

@ -1,82 +0,0 @@
use cucumber_rust::Steps;
use crate::MyWorld;
use xplr::app;
use xplr::input::Key;
pub fn steps() -> Steps<MyWorld> {
let mut steps: Steps<MyWorld> = Steps::new();
steps.given("xplr is running", |_world, _ctx| {
let app = app::App::create("/tmp/xplr_bdd".into()).unwrap();
std::thread::sleep(std::time::Duration::from_millis(500));
MyWorld::App(app)
});
steps.when_regex(r#"I press "(.*)"$"#, |world, ctx| match world {
MyWorld::App(app) => {
let k = &ctx.matches[1];
let key: Key = serde_yaml::from_str(&k).unwrap_or_else(|_| k.clone().into());
let msg = app::MsgIn::Internal(app::InternalMsg::HandleKey(key.clone()));
let task = app::Task::new(msg, Some(key));
MyWorld::App(app.handle_task(task).unwrap())
}
_ => {
panic!("invalid world state")
}
});
steps.when("xplr processes the tasks", |world, _ctx| match world {
MyWorld::App(app) => {
let mut app = app;
let mut msgs = vec![];
while let Some(msg) = app.pop_msg_out() {
match msg {
app::MsgOut::Enque(task) => {
app = app.handle_task(task).unwrap();
}
msg => {
msgs.push(msg);
}
}
}
MyWorld::MsgOutList(msgs)
}
_ => {
panic!("invalid world state")
}
});
steps.then_regex(r#"xplr performs "(.*)"$"#, |world, ctx| {
let mstr = &ctx.matches[1];
let msg = serde_yaml::from_str(&mstr).unwrap();
match world {
MyWorld::MsgOutList(msgs) => {
let mut msgs = msgs.into_iter();
assert_eq!(msgs.next(), Some(msg));
MyWorld::MsgOutList(msgs.collect())
}
_ => {
panic!("invalid world state")
}
}
});
steps.then(
"xplr quits or waits for the next event",
|world, _ctx| match world {
MyWorld::MsgOutList(msgs) => {
let mut msgs = msgs.into_iter();
assert_eq!(msgs.next(), None);
MyWorld::Nothing
}
_ => {
panic!("invalid world state")
}
},
);
steps
}

@ -1 +0,0 @@
pub mod key_bindings;
Loading…
Cancel
Save