Skip to content

Commit

Permalink
Remove duplicate file names when provided
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed Dec 6, 2024
1 parent 209685b commit 66ec0f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion notes.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
** TODO Improve build times
** TODO Include man page and shell completion in Nix package
** TODO Add to Nix home-manager with empty config file
** TODO Remove duplicate files from arguments
** TODO Add option for no config file
* Options and documentation
** Args struct
Expand Down
12 changes: 12 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,18 @@ impl Args {
/// Resolve conflicting arguments
pub fn resolve(&mut self, logs: &mut Vec<Log>) -> u8 {
let mut exit_code = 0;

// stdin implies print
self.print |= self.stdin;

// Set wrapmin
self.wrapmin = if self.wraplen >= 50 {
self.wraplen - 10
} else {
self.wraplen
};

// Check files are passed if no --stdin
if !self.stdin && self.files.is_empty() {
record_file_log(
logs,
Expand All @@ -144,6 +149,8 @@ impl Args {
);
exit_code = 1;
}

// Check no files are passed if --stdin
if self.stdin && !self.files.is_empty() {
record_file_log(
logs,
Expand All @@ -153,6 +160,11 @@ impl Args {
);
exit_code = 1;
}

// Remove duplicate files
self.files.dedup();

// Print arguments and exit
if self.arguments {
println!("{self}");
std::process::exit(0);
Expand Down

0 comments on commit 66ec0f4

Please sign in to comment.