Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update rust crate textwrap to 0.16 #233

Merged
merged 6 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/textwrap-0.16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-mobile2": "minor"
---

Update `textwrap` to 0.16.
86 changes: 70 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ once-cell-regex = "0.2"
path_abs = "0.5"
serde = { version = "1.0", features = [ "derive" ] }
structopt = { version = "0.3", optional = true }
textwrap = { version = "0.11", features = [ "term_size" ] }
textwrap = { version = "0.16", features = [ "terminal_size" ] }
thiserror = "1.0"
toml = { version = "0.5", features = [ "preserve_order" ] }
duct = "0.13"
Expand Down
1 change: 1 addition & 0 deletions src/android/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl Reportable for Error {
}
}

#[allow(clippy::too_many_arguments)]
pub fn gen(
config: &Config,
metadata: &Metadata,
Expand Down
11 changes: 7 additions & 4 deletions src/doctor/section/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,13 @@ impl Section {
pub fn print(&self, wrapper: &TextWrapper) {
static BULLET_INDENT: &str = " ";
static HANGING_INDENT: &str = " ";
let bullet_wrapper = wrapper
.clone()
.initial_indent(BULLET_INDENT)
.subsequent_indent(HANGING_INDENT);
let bullet_wrapper = TextWrapper(
wrapper
.clone()
.0
.initial_indent(BULLET_INDENT)
.subsequent_indent(HANGING_INDENT),
);
println!(
"\n{}",
// The `.to_string()` at the end is necessary for the color/bold to
Expand Down
1 change: 1 addition & 0 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl Reportable for Error {
}
}

#[allow(clippy::too_many_arguments)]
pub fn exec(
wrapper: &TextWrapper,
non_interactive: bool,
Expand Down
32 changes: 25 additions & 7 deletions src/util/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ pub use interface::*;

pub static VERSION_SHORT: &str = concat!("v", env!("CARGO_PKG_VERSION"));

pub type TextWrapper = textwrap::Wrapper<'static, textwrap::NoHyphenation>;
#[derive(Clone)]
pub struct TextWrapper(pub textwrap::Options<'static>);

impl Default for TextWrapper {
fn default() -> Self {
Self(
textwrap::Options::with_termwidth()
.word_splitter(textwrap::word_splitters::WordSplitter::NoHyphenation),
)
}
}

impl TextWrapper {
pub fn fill(&self, text: &str) -> String {
textwrap::fill(text, &self.0)
}
}

pub mod colors {
use colored::Color::{self, *};
Expand Down Expand Up @@ -93,10 +109,13 @@ impl Report {
} else {
wrapper.fill(&format!("{}: {}", self.label.as_str(), &self.msg))
};
let wrapper = wrapper
.clone()
.initial_indent(INDENT)
.subsequent_indent(INDENT);
let wrapper = TextWrapper(
wrapper
.clone()
.0
.initial_indent(INDENT)
.subsequent_indent(INDENT),
);
format!("{}\n{}\n", head, wrapper.fill(&self.details))
}

Expand Down Expand Up @@ -273,8 +292,7 @@ mod interface {
}

pub fn main(inner: impl FnOnce(&TextWrapper) -> Result<(), Self>) {
let wrapper =
TextWrapper::with_splitter(textwrap::termwidth(), textwrap::NoHyphenation);
let wrapper = TextWrapper::default();
if let Err(exit) = inner(&wrapper) {
exit.do_the_thing(wrapper)
}
Expand Down
33 changes: 12 additions & 21 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,14 @@ impl VersionTriple {

pub fn from_caps<'a>(caps: &'a Captures<'a>) -> Result<(Self, &'a str), VersionTripleError> {
let version_str = &caps["version"];
let parse_major = parse!("major", VersionTripleError, MajorInvalid, version);
let parse_minor = parse!("minor", VersionTripleError, MinorInvalid, version);
let parse_patch = parse!("patch", VersionTripleError, PatchInvalid, version);
Ok((
Self {
major: parse!("major", VersionTripleError, MajorInvalid, version)(
caps,
version_str,
)?,
minor: parse!("minor", VersionTripleError, MinorInvalid, version)(
caps,
version_str,
)?,
patch: parse!("patch", VersionTripleError, PatchInvalid, version)(
caps,
version_str,
)?,
major: parse_major(caps, version_str)?,
minor: parse_minor(caps, version_str)?,
patch: parse_patch(caps, version_str)?,
},
version_str,
))
Expand Down Expand Up @@ -425,18 +419,15 @@ impl RustVersion {
.name("details")
.map(|_details| -> Result<_, RustVersionError> {
let date_str = &caps["date"];
let parse_year = parse!("year", RustVersionError, YearInvalid, date);
let parse_month = parse!("month", RustVersionError, MonthInvalid, date);
let parse_day = parse!("day", RustVersionError, DayInvalid, date);
Ok(RustVersionDetails {
hash: caps["hash"].to_owned(),
date: (
parse!("year", RustVersionError, YearInvalid, date)(
&caps, date_str,
)?,
parse!("month", RustVersionError, MonthInvalid, date)(
&caps, date_str,
)?,
parse!("day", RustVersionError, DayInvalid, date)(
&caps, date_str,
)?,
parse_year(&caps, date_str)?,
parse_month(&caps, date_str)?,
parse_day(&caps, date_str)?,
),
})
})
Expand Down