prose: backport upstream clap patch.

This commit is contained in:
Leah Neukirchen 2023-04-02 14:30:52 +02:00
parent e896393544
commit 385e85b6e3
2 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,56 @@
From 037bf5b8e14fc0b8b25e00e2e076515148860825 Mon Sep 17 00:00:00 2001
From: Joshua Davey <josh@joshuadavey.com>
Date: Sat, 10 Dec 2022 16:28:29 -0500
Subject: [PATCH] Use usize parser from clap
---
src/main.rs | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index efb0420..fb0e8ad 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,16 +29,14 @@ fn process_paragraphs<R: BufRead + ?Sized>(io: &mut R, opts: FormatOpts) -> io::
fn matches_to_format_opts(matches: &clap::ArgMatches) -> FormatOpts {
let width: usize = matches
- .get_one::<&str>("width")
- .unwrap()
- .parse()
+ .get_one::<usize>("width")
+ .cloned()
.expect("Choose a positive number for width");
let last_line = matches.get_flag("last line");
let reduce_jaggedness = matches.get_flag("better fit");
let tab_width: usize = matches
- .get_one::<&str>("tab width")
- .unwrap()
- .parse()
+ .get_one::<usize>("tab width")
+ .cloned()
.expect("Choose a positive number for tab width");
let format_mode = if matches.get_flag("markdown") {
FormatMode::Markdown
@@ -71,6 +69,7 @@ fn main() {
.short('w')
.long("width")
.value_name("WIDTH")
+ .value_parser(clap::value_parser!(usize))
.default_value("72")
.help("Sets the maximum width for a line"))
.arg(Arg::new("last line")
@@ -86,11 +85,13 @@ fn main() {
.arg(Arg::new("tab width")
.short('t')
.long("tab-width")
+ .value_parser(clap::value_parser!(usize))
.default_value("4")
.help("Number of spaces to expand tab characters to"))
.arg(Arg::new("markdown")
.short('m')
.long("markdown")
+ .conflicts_with("code comments")
.help("Parse as markdown rather than plain text")
.action(ArgAction::SetTrue))
.arg(Arg::new("FILE")

View File

@ -1,7 +1,7 @@
# Template file for 'prose'
pkgname=prose
version=0.4.0
revision=1
revision=2
build_style=cargo
short_desc="Reformat text pleasantly"
maintainer="Leah Neukirchen <leah@vuxu.org>"