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

Adds "almost all" flag (-A) for compatibility with zsh's la alias #1049

Closed
wants to merge 2 commits into from
Closed
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: 3 additions & 2 deletions src/options/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ impl DotFilter {
/// parent directory in tree mode would loop onto itself!
pub fn deduce(matches: &MatchedFlags<'_>) -> Result<Self, OptionsError> {
let count = matches.count(&flags::ALL);
let almost_count = matches.count(&flags::ALMOST_ALL);

if count == 0 {
if count == 0 && almost_count == 0 {
Ok(Self::JustFiles)
}
else if count == 1 {
else if count == 1 || almost_count == 1 {
Ok(Self::Dotfiles)
}
else if matches.count(&flags::TREE) > 0 {
Expand Down
3 changes: 2 additions & 1 deletion src/options/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub static COLOUR_SCALE: Arg = Arg { short: None, long: "colour-scale", takes_va

// filtering and sorting options
pub static ALL: Arg = Arg { short: Some(b'a'), long: "all", takes_value: TakesValue::Forbidden };
pub static ALMOST_ALL: Arg = Arg { short: Some(b'A'), long: "allmost-all", takes_value: TakesValue::Forbidden };
pub static LIST_DIRS: Arg = Arg { short: Some(b'd'), long: "list-dirs", takes_value: TakesValue::Forbidden };
pub static LEVEL: Arg = Arg { short: Some(b'L'), long: "level", takes_value: TakesValue::Necessary(None) };
pub static REVERSE: Arg = Arg { short: Some(b'r'), long: "reverse", takes_value: TakesValue::Forbidden };
Expand Down Expand Up @@ -73,7 +74,7 @@ pub static ALL_ARGS: Args = Args(&[
&ONE_LINE, &LONG, &GRID, &ACROSS, &RECURSE, &TREE, &CLASSIFY,
&COLOR, &COLOUR, &COLOR_SCALE, &COLOUR_SCALE,

&ALL, &LIST_DIRS, &LEVEL, &REVERSE, &SORT, &DIRS_FIRST,
&ALL, &ALMOST_ALL, &LIST_DIRS, &LEVEL, &REVERSE, &SORT, &DIRS_FIRST,
&IGNORE_GLOB, &GIT_IGNORE, &ONLY_DIRS,

&BINARY, &BYTES, &GROUP, &NUMERIC, &HEADER, &ICONS, &INODE, &LINKS, &MODIFIED, &CHANGED,
Expand Down