diff --git a/plugins/plugin-bash-like/fs/src/lib/ls.ts b/plugins/plugin-bash-like/fs/src/lib/ls.ts index e76c99b667d..accefb8d3df 100644 --- a/plugins/plugin-bash-like/fs/src/lib/ls.ts +++ b/plugins/plugin-bash-like/fs/src/lib/ls.ts @@ -67,7 +67,7 @@ function prettyTime(ms: number): string { return dateFormatter(new Date(ms)).replace(/(\s)0/g, '$1 ') } -interface LsOptions extends ParsedOptions { +interface TheLsOptions { l: boolean // wide output a: boolean // list with dots except for . and .. A: boolean // list with dots @@ -78,6 +78,8 @@ interface LsOptions extends ParsedOptions { d: boolean // don't traverse directories } +type LsOptions = TheLsOptions & ParsedOptions + /** sort by size */ const bySize = (rev: -1 | 1) => (a: GlobStats, b: GlobStats): number => { return rev * (b.stats.size - a.stats.size) @@ -236,6 +238,11 @@ function toTable(entries: GlobStats[], args: Arguments): Table { } } +/** Format a dash option, if specified */ +function opt(o: keyof TheLsOptions, opts: Arguments) { + return opts.parsedOptions[o] ? ` -${o} ` : '' +} + /** * ls command handler * @@ -257,7 +264,7 @@ const doLs = (cmd: string) => async (opts: Arguments): Promise