From e39bd211d1579bfafa1774f6915af5725041781e Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 1 Oct 2020 12:23:07 +0900 Subject: argh -> clap to speed up compilation (no syn/proc_macro) --- helix-term/Cargo.toml | 7 ++++--- helix-term/src/editor.rs | 4 ++-- helix-term/src/main.rs | 21 ++++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) (limited to 'helix-term') diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml index ecbbe7d2..82eeb345 100644 --- a/helix-term/Cargo.toml +++ b/helix-term/Cargo.toml @@ -15,9 +15,10 @@ helix-core = { path = "../helix-core" } helix-view = { path = "../helix-view", features = ["term"]} anyhow = "1" -argh = "0.1" smol = "1" num_cpus = "1.13" -tui = { version = "0.11", default-features = false, features = ["crossterm"] } -crossterm = { version = "0.17", features = ["event-stream"] } +# tui = { version = "0.12", default-features = false, features = ["crossterm"] } +tui = { git = "https://github.com/fdehau/tui-rs", default-features = false, features = ["crossterm"] } +crossterm = { version = "0.18", features = ["event-stream"] } +clap = { version = "3.0.0-beta.2 ", default-features = false, features = ["std"] } diff --git a/helix-term/src/editor.rs b/helix-term/src/editor.rs index 2cc210f4..b745eff2 100644 --- a/helix-term/src/editor.rs +++ b/helix-term/src/editor.rs @@ -1,4 +1,4 @@ -use crate::Args; +use clap::ArgMatches as Args; use helix_core::{state::coords_at_pos, state::Mode, syntax::HighlightEvent, Range, State}; use helix_view::{commands, keymap, View}; @@ -53,7 +53,7 @@ impl Editor { // TODO; move to state }; - if let Some(file) = args.files.pop() { + if let Some(file) = args.values_of_t::("files").unwrap().pop() { editor.open(file)?; } diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index b691eb65..eeb498bc 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -4,22 +4,25 @@ mod editor; use editor::Editor; -use argh::FromArgs; +use clap::{App, Arg}; use std::path::PathBuf; use anyhow::Error; -#[derive(FromArgs)] -/// A post-modern text editor. -pub struct Args { - #[argh(positional)] - files: Vec, -} - static EX: smol::Executor = smol::Executor::new(); fn main() -> Result<(), Error> { - let args: Args = argh::from_env(); + let args = App::new("helix") + .version("0.1") + .about("A post-modern text editor.") + .arg( + Arg::new("files") + .about("Sets the input file to use") + .required(true) + .multiple(true) + .index(1), + ) + .get_matches(); for _ in 0..num_cpus::get() { std::thread::spawn(move || smol::block_on(EX.run(smol::future::pending::<()>()))); -- cgit v1.2.3-70-g09d2