mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
ls: Add option -1 which lists one file per line
This commit is contained in:
parent
70f3fa2dd2
commit
1ad7aa7136
Notes:
sideshowbarker
2024-07-17 18:30:23 +09:00
Author: https://github.com/elttil 🔰 Commit: https://github.com/SerenityOS/serenity/commit/1ad7aa7136 Pull-request: https://github.com/SerenityOS/serenity/pull/12670
@ -32,6 +32,7 @@ If no *path* argument is provided the current working directory is used.
|
||||
* `-h`, `--human-readable`: Print human-readable sizes
|
||||
* `-K`, `--no-hyperlinks`: Disable hyperlinks
|
||||
* `-R`, `--recursive`: List subdirectories recursively
|
||||
* `-1`: List one file per line
|
||||
|
||||
## Arguments
|
||||
|
||||
|
@ -64,6 +64,7 @@ static bool flag_sort_by_timestamp = false;
|
||||
static bool flag_reverse_sort = false;
|
||||
static bool flag_disable_hyperlinks = false;
|
||||
static bool flag_recursive = false;
|
||||
static bool flag_force_newline = false;
|
||||
|
||||
static size_t terminal_rows = 0;
|
||||
static size_t terminal_columns = 0;
|
||||
@ -117,6 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
args_parser.add_option(flag_human_readable, "Print human-readable sizes", "human-readable", 'h');
|
||||
args_parser.add_option(flag_disable_hyperlinks, "Disable hyperlinks", "no-hyperlinks", 'K');
|
||||
args_parser.add_option(flag_recursive, "List subdirectories recursively", "recursive", 'R');
|
||||
args_parser.add_option(flag_force_newline, "List one file per line", nullptr, '1');
|
||||
args_parser.add_positional_argument(paths, "Directory to list", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
@ -480,7 +482,7 @@ static bool print_names(const char* path, size_t longest_name, const Vector<File
|
||||
for (size_t j = nprinted; i != (files.size() - 1) && j < column_width; ++j)
|
||||
printf(" ");
|
||||
}
|
||||
if ((printed_on_row + column_width) >= terminal_columns) {
|
||||
if ((printed_on_row + column_width) >= terminal_columns || flag_force_newline) {
|
||||
printf("\n");
|
||||
printed_on_row = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user