Drop clap for pico-args

We barely have any flags so it's not worth the compilation time or
binary size to use clap.
pull/19/head
Blaž Hrastnik 4 years ago
parent 1132c5122f
commit 138787f76e

61
Cargo.lock generated

@ -77,21 +77,6 @@ dependencies = [
"winapi", "winapi",
] ]
[[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]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.4" version = "0.8.4"
@ -272,17 +257,10 @@ dependencies = [
"regex", "regex",
] ]
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]] [[package]]
name = "helix-core" name = "helix-core"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow",
"etcetera", "etcetera",
"helix-syntax", "helix-syntax",
"once_cell", "once_cell",
@ -335,7 +313,6 @@ version = "0.1.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
"clap",
"crossterm", "crossterm",
"dirs-next", "dirs-next",
"fern", "fern",
@ -349,6 +326,7 @@ dependencies = [
"log", "log",
"num_cpus", "num_cpus",
"once_cell", "once_cell",
"pico-args",
"pulldown-cmark", "pulldown-cmark",
"serde", "serde",
"serde_json", "serde_json",
@ -423,16 +401,6 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "indexmap"
version = "1.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.9" version = "0.1.9"
@ -602,12 +570,6 @@ version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
[[package]]
name = "os_str_bytes"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afb2e1c3ee07430c2cf76151675e583e0f19985fa6efae47d6848a3e2c824f85"
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.11.1" version = "0.11.1"
@ -645,6 +607,12 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pico-args"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d7afeb98c5a10e0bffcc7fc16e105b04d06729fac5fd6384aebf7ff5cb5a67d"
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.6" version = "0.2.6"
@ -857,15 +825,6 @@ dependencies = [
"utf-8", "utf-8",
] ]
[[package]]
name = "textwrap"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "203008d98caf094106cfaba70acfed15e18ed3ddb7d94e49baec153a2b462789"
dependencies = [
"unicode-width",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.25" version = "1.0.25"
@ -1044,12 +1003,6 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.3" version = "0.9.3"

@ -11,7 +11,6 @@ license = "MPL-2.0"
helix-syntax = { path = "../helix-syntax" } helix-syntax = { path = "../helix-syntax" }
ropey = "1.2" ropey = "1.2"
anyhow = "1"
smallvec = "1.4" smallvec = "1.4"
tendril = "0.4.2" tendril = "0.4.2"
unicode-segmentation = "1.6" unicode-segmentation = "1.6"

@ -24,7 +24,7 @@ tokio = { version = "1", features = ["full"] }
num_cpus = "1" num_cpus = "1"
tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"] } tui = { path = "../helix-tui", package = "helix-tui", default-features = false, features = ["crossterm"] }
crossterm = { version = "0.19", features = ["event-stream"] } 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 } futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }

@ -1,8 +1,6 @@
use clap::ArgMatches as Args;
use helix_view::{document::Mode, Document, Editor, Theme, View}; use helix_view::{document::Mode, Document, Editor, Theme, View};
use crate::{compositor::Compositor, ui}; use crate::{compositor::Compositor, ui, Args};
use log::{error, info}; use log::{error, info};
@ -47,8 +45,8 @@ impl Application {
let size = compositor.size(); let size = compositor.size();
let mut editor = Editor::new(size); let mut editor = Editor::new(size);
if let Ok(files) = args.values_of_t::<PathBuf>("files") { if !args.files.is_empty() {
for file in files { for file in args.files {
editor.open(file, Action::VerticalSplit)?; editor.open(file, Action::VerticalSplit)?;
} }
} else { } else {

@ -8,7 +8,6 @@ mod ui;
use application::Application; use application::Application;
use clap::{App, Arg};
use std::path::PathBuf; use std::path::PathBuf;
use anyhow::Error; use anyhow::Error;
@ -48,25 +47,48 @@ fn setup_logging(verbosity: u64) -> Result<(), fern::InitError> {
Ok(()) Ok(())
} }
pub struct Args {
files: Vec<PathBuf>,
}
fn main() { fn main() {
let args = clap::app_from_crate!() let help = format!(
.arg( "\
Arg::new("files") {} {}
.about("Sets the input file to use") {}
.required(false) {}
.multiple(true)
.index(1), USAGE:
) hx [FLAGS] [files]...
.arg(
Arg::new("verbose") ARGS:
.about("Increases logging verbosity each use for up to 3 times") <files>... Sets the input file to use
.short('v')
.takes_value(false) FLAGS:
.multiple_occurrences(true), -h, --help Prints help information
) -v Increases logging verbosity each use for up to 3 times
.get_matches(); -V, --version Prints version information
",
let verbosity: u64 = args.occurrences_of("verbose"); 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."); setup_logging(verbosity).expect("failed to initialize logging.");

Loading…
Cancel
Save