Drop clap for pico-args

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

61
Cargo.lock generated

@ -77,21 +77,6 @@ dependencies = [
"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]]
name = "crossbeam-utils"
version = "0.8.4"
@ -272,17 +257,10 @@ dependencies = [
"regex",
]
[[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",
@ -423,16 +401,6 @@ dependencies = [
"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]]
name = "instant"
version = "0.1.9"
@ -602,12 +570,6 @@ version = "1.7.2"
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"
@ -645,6 +607,12 @@ version = "2.1.0"
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"
@ -857,15 +825,6 @@ dependencies = [
"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]]
name = "thiserror"
version = "1.0.25"
@ -1044,12 +1003,6 @@ version = "0.7.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"

@ -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"

@ -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 }

@ -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 {

@ -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.");

Loading…
Cancel
Save