mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 20:17:45 +00:00
fmt: implement default for FmtOptions
This commit is contained in:
parent
8940018833
commit
42d6604e59
1 changed files with 25 additions and 17 deletions
|
@ -60,25 +60,10 @@ pub struct FmtOptions {
|
|||
goal: usize,
|
||||
tabwidth: usize,
|
||||
}
|
||||
/// Parse the command line arguments and return the list of files and formatting options.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `args` - Command line arguments.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A tuple containing a vector of file names and a `FmtOptions` struct.
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec<String>, FmtOptions)> {
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
let mut files: Vec<String> = matches
|
||||
.get_many::<String>(ARG_FILES)
|
||||
.map(|v| v.map(ToString::to_string).collect())
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut fmt_opts = FmtOptions {
|
||||
impl Default for FmtOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
crown: false,
|
||||
tagged: false,
|
||||
mail: false,
|
||||
|
@ -94,7 +79,30 @@ fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec<String>, FmtOptions)
|
|||
width: 79,
|
||||
goal: 74,
|
||||
tabwidth: 8,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse the command line arguments and return the list of files and formatting options.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `args` - Command line arguments.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A tuple containing a vector of file names and a `FmtOptions` struct.
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
#[allow(clippy::field_reassign_with_default)]
|
||||
fn parse_arguments(args: impl uucore::Args) -> UResult<(Vec<String>, FmtOptions)> {
|
||||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
let mut files: Vec<String> = matches
|
||||
.get_many::<String>(ARG_FILES)
|
||||
.map(|v| v.map(ToString::to_string).collect())
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut fmt_opts = FmtOptions::default();
|
||||
|
||||
fmt_opts.tagged = matches.get_flag(OPT_TAGGED_PARAGRAPH);
|
||||
if matches.get_flag(OPT_CROWN_MARGIN) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue