Skip to content

Commit

Permalink
Implement CLI arguments
Browse files Browse the repository at this point in the history
Going with custom CLI parsing for minimalism and flexibility.

Closes: #228
  • Loading branch information
sayanarijit committed Jun 5, 2021
1 parent a1a1dee commit fabcc8e
Show file tree
Hide file tree
Showing 10 changed files with 322 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
override: true
# These dependencies are required for `clipboard`
- run: sudo apt-get install -y -qq libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- uses: actions-rs/cargo@v1
with:
command: build
- uses: actions-rs/cargo@v1
with:
command: test
Expand Down
70 changes: 69 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xplr"
version = "0.13.6" # Update lua.rs
version = "0.13.7" # Update lua.rs
authors = ["Arijit Basu <sayanarijit@gmail.com>"]
edition = "2018"
description = "A hackable, minimal, fast TUI file explorer"
Expand All @@ -14,6 +14,9 @@ categories = ["command-line-interface", "command-line-utilities"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[bin]]
name = "xplr"

[dependencies]
tui = { version = "0.15.0", default-features = false, features = ['crossterm', 'serde'] }
termion = "1.5.6"
Expand All @@ -34,6 +37,7 @@ libc = "0.2.95"

[dev-dependencies]
criterion = "0.3"
assert_cmd = "1.0"

[[bench]]
name = "criterion"
Expand Down
2 changes: 1 addition & 1 deletion examples/run.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
let pwd = std::path::PathBuf::from("/");
match xplr::run(pwd, None) {
match xplr::run(pwd, None, None) {
Ok(Some(out)) => print!("{}", out),
Ok(None) => {}
Err(err) => {
Expand Down
13 changes: 11 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2803,8 +2803,17 @@ impl App {
}

/// Run xplr TUI
pub fn run(pwd: PathBuf, focused_path: Option<PathBuf>) -> Result<Option<String>> {
pub fn run(
pwd: PathBuf,
focused_path: Option<PathBuf>,
on_load: Option<Vec<ExternalMsg>>,
) -> Result<Option<String>> {
let lua = mlua::Lua::new();
let app = App::create(pwd, &lua)?;
let mut app = App::create(pwd, &lua)?;
if let Some(msgs) = on_load {
for msg in msgs {
app = app.enqueue(Task::new(MsgIn::External(msg), None));
}
}
app.run(focused_path, &lua)
}
Loading

0 comments on commit fabcc8e

Please sign in to comment.