aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock61
-rw-r--r--helix-core/Cargo.toml1
-rw-r--r--helix-term/Cargo.toml2
-rw-r--r--helix-term/src/application.rs8
-rw-r--r--helix-term/src/main.rs60
5 files changed, 52 insertions, 80 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 65c55fdf..7118029c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -78,21 +78,6 @@ dependencies = [
]
[[package]]
-name = "clap"
-version = "3.0.0-beta.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4bd1061998a501ee7d4b6d449020df3266ca3124b941ec56cf2005c3779ca142"
-dependencies = [
- "bitflags",
- "indexmap",
- "lazy_static",
- "os_str_bytes",
- "textwrap",
- "unicode-width",
- "vec_map",
-]
-
-[[package]]
name = "crossbeam-utils"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -273,16 +258,9 @@ dependencies = [
]
[[package]]
-name = "hashbrown"
-version = "0.9.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
-
-[[package]]
name = "helix-core"
version = "0.1.0"
dependencies = [
- "anyhow",
"etcetera",
"helix-syntax",
"once_cell",
@@ -335,7 +313,6 @@ version = "0.1.0"
dependencies = [
"anyhow",
"chrono",
- "clap",
"crossterm",
"dirs-next",
"fern",
@@ -349,6 +326,7 @@ dependencies = [
"log",
"num_cpus",
"once_cell",
+ "pico-args",
"pulldown-cmark",
"serde",
"serde_json",
@@ -424,16 +402,6 @@ dependencies = [
]
[[package]]
-name = "indexmap"
-version = "1.6.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
-dependencies = [
- "autocfg",
- "hashbrown",
-]
-
-[[package]]
name = "instant"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -603,12 +571,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
[[package]]
-name = "os_str_bytes"
-version = "2.4.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85"
-
-[[package]]
name = "parking_lot"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -646,6 +608,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
+name = "pico-args"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d7afeb98c5a10e0bffcc7fc16e105b04d06729fac5fd6384aebf7ff5cb5a67d"
+
+[[package]]
name = "pin-project-lite"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -858,15 +826,6 @@ dependencies = [
]
[[package]]
-name = "textwrap"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
-dependencies = [
- "unicode-width",
-]
-
-[[package]]
name = "thiserror"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1045,12 +1004,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/helix-core/Cargo.toml b/helix-core/Cargo.toml
index 33b59cb1..b5f2ef77 100644
--- a/helix-core/Cargo.toml
+++ b/helix-core/Cargo.toml
@@ -11,7 +11,6 @@ license = "MPL-2.0"
helix-syntax = { path = "../helix-syntax" }
ropey = "1.2"
-anyhow = "1"
smallvec = "1.4"
tendril = "0.4.2"
unicode-segmentation = "1.6"
diff --git a/helix-term/Cargo.toml b/helix-term/Cargo.toml
index af710151..ece32395 100644
--- a/helix-term/Cargo.toml
+++ b/helix-term/Cargo.toml
@@ -24,7 +24,7 @@ tokio = { version = "1", features = ["full"] }
num_cpus = "1"
tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"] }
crossterm = { version = "0.19", features = ["event-stream"] }
-clap = { version = "3.0.0-beta.2 ", default-features = false, features = ["std", "cargo"] }
+pico-args = "0.4"
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 42a46f1e..5ea6be2b 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -1,8 +1,6 @@
-use clap::ArgMatches as Args;
-
use helix_view::{document::Mode, Document, Editor, Theme, View};
-use crate::{compositor::Compositor, ui};
+use crate::{compositor::Compositor, ui, Args};
use log::{error, info};
@@ -47,8 +45,8 @@ impl Application {
let size = compositor.size();
let mut editor = Editor::new(size);
- if let Ok(files) = args.values_of_t::<PathBuf>("files") {
- for file in files {
+ if !args.files.is_empty() {
+ for file in args.files {
editor.open(file, Action::VerticalSplit)?;
}
} else {
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs
index 386c2333..9ca5b067 100644
--- a/helix-term/src/main.rs
+++ b/helix-term/src/main.rs
@@ -8,7 +8,6 @@ mod ui;
use application::Application;
-use clap::{App, Arg};
use std::path::PathBuf;
use anyhow::Error;
@@ -48,25 +47,48 @@ fn setup_logging(verbosity: u64) -> Result<(), fern::InitError> {
Ok(())
}
+pub struct Args {
+ files: Vec<PathBuf>,
+}
+
fn main() {
- let args = clap::app_from_crate!()
- .arg(
- Arg::new("files")
- .about("Sets the input file to use")
- .required(false)
- .multiple(true)
- .index(1),
- )
- .arg(
- Arg::new("verbose")
- .about("Increases logging verbosity each use for up to 3 times")
- .short('v')
- .takes_value(false)
- .multiple_occurrences(true),
- )
- .get_matches();
-
- let verbosity: u64 = args.occurrences_of("verbose");
+ let help = format!(
+ "\
+{} {}
+{}
+{}
+
+USAGE:
+ hx [FLAGS] [files]...
+
+ARGS:
+ <files>... Sets the input file to use
+
+FLAGS:
+ -h, --help Prints help information
+ -v Increases logging verbosity each use for up to 3 times
+ -V, --version Prints version information
+",
+ env!("CARGO_PKG_NAME"),
+ env!("CARGO_PKG_VERSION"),
+ env!("CARGO_PKG_AUTHORS"),
+ env!("CARGO_PKG_DESCRIPTION"),
+ );
+
+ let mut pargs = pico_args::Arguments::from_env();
+
+ // Help has a higher priority and should be handled separately.
+ if pargs.contains(["-h", "--help"]) {
+ print!("{}", help);
+ std::process::exit(0);
+ }
+
+ let args = Args {
+ files: pargs.finish().into_iter().map(|arg| arg.into()).collect(),
+ };
+
+ // let verbosity: u64 = args.occurrences_of("verbose");
+ let verbosity: u64 = 0;
setup_logging(verbosity).expect("failed to initialize logging.");