From 9fb6f5cd090533e0c9472cdd93c6993a9c93eb75 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Sat, 1 Aug 2020 14:30:45 -0400 Subject: [PATCH] Change `f`/`full` flag to `l`/`long` for `ls` and `ps` commands (#2283) * Change `f`/`full` flag to `l`/`long` for `ls` and `ps` commands * Fix a few more `--full` instances --- crates/nu-cli/src/commands/compact.rs | 2 +- crates/nu-cli/src/commands/default.rs | 2 +- crates/nu-cli/src/commands/ls.rs | 17 +++++++++-------- crates/nu-cli/src/data/files.rs | 10 +++++----- crates/nu-cli/src/shell/filesystem_shell.rs | 4 ++-- crates/nu-cli/tests/commands/ls.rs | 6 +++--- crates/nu-parser/src/parse.rs | 4 ++-- crates/nu_plugin_ps/src/nu/mod.rs | 6 +++--- crates/nu_plugin_ps/src/ps.rs | 4 ++-- docs/commands/histogram.md | 2 +- docs/commands/history.md | 2 +- docs/commands/where.md | 4 ++-- docs/sample_config/config.toml | 4 ++-- 13 files changed, 34 insertions(+), 33 deletions(-) diff --git a/crates/nu-cli/src/commands/compact.rs b/crates/nu-cli/src/commands/compact.rs index c746e3d5b5..24dff5b559 100644 --- a/crates/nu-cli/src/commands/compact.rs +++ b/crates/nu-cli/src/commands/compact.rs @@ -49,7 +49,7 @@ impl WholeStreamCommand for Compact { }, Example { description: "Filter out all directory entries having no 'target'", - example: "ls -af | compact target", + example: "ls -la | compact target", result: None, }, ] diff --git a/crates/nu-cli/src/commands/default.rs b/crates/nu-cli/src/commands/default.rs index 83c69bcd1f..ffe0671da5 100644 --- a/crates/nu-cli/src/commands/default.rs +++ b/crates/nu-cli/src/commands/default.rs @@ -45,7 +45,7 @@ impl WholeStreamCommand for Default { fn examples(&self) -> Vec { vec![Example { description: "Give a default 'target' to all file entries", - example: "ls -af | default target 'nothing'", + example: "ls -la | default target 'nothing'", result: None, }] } diff --git a/crates/nu-cli/src/commands/ls.rs b/crates/nu-cli/src/commands/ls.rs index cd25fa92ec..ae3ac26ccd 100644 --- a/crates/nu-cli/src/commands/ls.rs +++ b/crates/nu-cli/src/commands/ls.rs @@ -11,7 +11,7 @@ pub struct Ls; pub struct LsArgs { pub path: Option>, pub all: bool, - pub full: bool, + pub long: bool, #[serde(rename = "short-names")] pub short_names: bool, #[serde(rename = "with-symlink-targets")] @@ -33,25 +33,26 @@ impl WholeStreamCommand for Ls { SyntaxShape::Pattern, "a path to get the directory contents from", ) - .switch("all", "also show hidden files", Some('a')) + .switch("all", "Show hidden files", Some('a')) .switch( - "full", - "list all available columns for each entry", - Some('f'), + "long", + "List all available columns for each entry", + Some('l'), ) .switch( "short-names", - "only print the file names and not the path", + "Only print the file names and not the path", Some('s'), ) .switch( + // Delete this "with-symlink-targets", - "display the paths to the target files that symlinks point to", + "Display the paths to the target files that symlinks point to", Some('w'), ) .switch( "du", - "display the apparent directory size in place of the directory metadata size", + "Display the apparent directory size in place of the directory metadata size", Some('d'), ) } diff --git a/crates/nu-cli/src/data/files.rs b/crates/nu-cli/src/data/files.rs index d2eaeda030..4bdeada8e1 100644 --- a/crates/nu-cli/src/data/files.rs +++ b/crates/nu-cli/src/data/files.rs @@ -37,7 +37,7 @@ pub(crate) fn dir_entry_dict( filename: &std::path::Path, metadata: Option<&std::fs::Metadata>, tag: impl Into, - full: bool, + long: bool, short_name: bool, with_symlink_targets: bool, du: bool, @@ -46,7 +46,7 @@ pub(crate) fn dir_entry_dict( let tag = tag.into(); let mut dict = TaggedDictBuilder::new(&tag); // Insert all columns first to maintain proper table alignment if we can't find (or are not allowed to view) any information - if full { + if long { #[cfg(windows)] { for column in [ @@ -97,7 +97,7 @@ pub(crate) fn dir_entry_dict( dict.insert_untagged("type", get_file_type(md)); } - if full || with_symlink_targets { + if long || with_symlink_targets { if let Some(md) = metadata { if md.file_type().is_symlink() { let symlink_target_untagged_value: UntaggedValue; @@ -113,7 +113,7 @@ pub(crate) fn dir_entry_dict( } } - if full { + if long { if let Some(md) = metadata { dict.insert_untagged( "readonly", @@ -181,7 +181,7 @@ pub(crate) fn dir_entry_dict( } if let Some(md) = metadata { - if full { + if long { if let Ok(c) = md.created() { dict.insert_untagged("created", UntaggedValue::system_date(c)); } diff --git a/crates/nu-cli/src/shell/filesystem_shell.rs b/crates/nu-cli/src/shell/filesystem_shell.rs index 7bd10857e6..69dd2300d5 100644 --- a/crates/nu-cli/src/shell/filesystem_shell.rs +++ b/crates/nu-cli/src/shell/filesystem_shell.rs @@ -95,7 +95,7 @@ impl Shell for FilesystemShell { LsArgs { path, all, - full, + long, short_names, with_symlink_targets, du, @@ -164,7 +164,7 @@ impl Shell for FilesystemShell { &path, metadata.as_ref(), name_tag.clone(), - full, + long, short_names, with_symlink_targets, du, diff --git a/crates/nu-cli/tests/commands/ls.rs b/crates/nu-cli/tests/commands/ls.rs index 632b2131c5..bbc907e72e 100644 --- a/crates/nu-cli/tests/commands/ls.rs +++ b/crates/nu-cli/tests/commands/ls.rs @@ -180,10 +180,10 @@ fn list_all_columns() { ); let expected = ["name", "type", "target", "size", "modified"].join(""); assert_eq!(actual.out, expected, "column names are incorrect for ls -w"); - // Full + // Long let actual = nu!( cwd: dirs.test(), - "ls -f | get | to md" + "ls -l | get | to md" ); let expected = { #[cfg(unix)] @@ -206,7 +206,7 @@ fn list_all_columns() { }; assert_eq!( actual.out, expected, - "column names are incorrect for ls full" + "column names are incorrect for ls long" ); }, ); diff --git a/crates/nu-parser/src/parse.rs b/crates/nu-parser/src/parse.rs index bc34fdf69e..c5ab69e684 100644 --- a/crates/nu-parser/src/parse.rs +++ b/crates/nu-parser/src/parse.rs @@ -805,8 +805,8 @@ mod test { } } -/// Match the available flags in a signature with what the user provided. This will check both long-form flags (--full) and shorthand flags (-f) -/// This also allows users to provide a group of shorthand flags (-af) that correspond to multiple shorthand flags at once. +/// Match the available flags in a signature with what the user provided. This will check both long-form flags (--long) and shorthand flags (-l) +/// This also allows users to provide a group of shorthand flags (-la) that correspond to multiple shorthand flags at once. fn get_flags_from_flag( signature: &nu_protocol::Signature, cmd: &Spanned, diff --git a/crates/nu_plugin_ps/src/nu/mod.rs b/crates/nu_plugin_ps/src/nu/mod.rs index 7801ecb898..7604b31284 100644 --- a/crates/nu_plugin_ps/src/nu/mod.rs +++ b/crates/nu_plugin_ps/src/nu/mod.rs @@ -10,15 +10,15 @@ impl Plugin for Ps { Ok(Signature::build("ps") .desc("View information about system processes.") .switch( - "full", + "long", "list all available columns for each entry", - Some('f'), + Some('l'), ) .filter()) } fn begin_filter(&mut self, callinfo: CallInfo) -> Result, ShellError> { - Ok(block_on(ps(callinfo.name_tag, callinfo.args.has("full")))? + Ok(block_on(ps(callinfo.name_tag, callinfo.args.has("long")))? .into_iter() .map(ReturnSuccess::value) .collect()) diff --git a/crates/nu_plugin_ps/src/ps.rs b/crates/nu_plugin_ps/src/ps.rs index cb80c0d9ac..28be7007a0 100644 --- a/crates/nu_plugin_ps/src/ps.rs +++ b/crates/nu_plugin_ps/src/ps.rs @@ -28,7 +28,7 @@ async fn usage(process: Process) -> ProcessResult<(process::Process, Ratio, proc Ok((process, usage_2 - usage_1, memory)) } -pub async fn ps(tag: Tag, full: bool) -> Result, ShellError> { +pub async fn ps(tag: Tag, long: bool) -> Result, ShellError> { let processes = process::processes() .await .map_err(|_| { @@ -67,7 +67,7 @@ pub async fn ps(tag: Tag, full: bool) -> Result, ShellError> { "virtual", UntaggedValue::filesize(memory.vms().get::()), ); - if full { + if long { if let Ok(parent_pid) = process.parent_pid().await { dict.insert_untagged("parent", UntaggedValue::int(parent_pid)) } diff --git a/docs/commands/histogram.md b/docs/commands/histogram.md index 8db4aad903..c610a1ebb9 100644 --- a/docs/commands/histogram.md +++ b/docs/commands/histogram.md @@ -81,7 +81,7 @@ We can also set the name of the second column or sort the table: Of course, histogram operations are not restricted to just analyzing numbers in files, you can also analyze your directories ```shell -> ls -fa | histogram type | sort-by count +> ls -la | histogram type | sort-by count ───┬─────────┬───────┬────────────────────────────────────────────────────────────────────────────────────────────────────── # │ type │ count │ frequency ───┼─────────┼───────┼────────────────────────────────────────────────────────────────────────────────────────────────────── diff --git a/docs/commands/history.md b/docs/commands/history.md index 1847d1389c..1cbe8016bc 100644 --- a/docs/commands/history.md +++ b/docs/commands/history.md @@ -12,6 +12,6 @@ Displays the last 100 commands. ... 97 │ date 98 │ ls - 99 │ ls -fa + 99 │ ls -la ─────┴──────────────────────────────────────────────────────────────────────── ``` diff --git a/docs/commands/where.md b/docs/commands/where.md index 7ef791fab0..c400067045 100644 --- a/docs/commands/where.md +++ b/docs/commands/where.md @@ -35,7 +35,7 @@ Dates can also be compared using the duration types. For example, `where accesse ## Boolean check -Where with the form `| where readonly` is used to check boolean values. For example, the command `ls --full | where readonly` will list only those files that are readonly. +Where with the form `| where readonly` is used to check boolean values. For example, the command `ls --long | where readonly` will list only those files that are readonly. ## Usage @@ -76,7 +76,7 @@ Where with the form `| where readonly` is used to check boolean values. For exam ``` ```shell -> ls -f | where accessed <= 1w +> ls -l | where accessed <= 1w ───┬────────────────────┬──────┬────────┬──────────┬───────────┬─────────────┬───────┬──────────┬──────────────┬─────────────┬───────────── # │ name │ type │ target │ readonly │ mode │ uid │ group │ size │ created │ accessed │ modified ───┼────────────────────┼──────┼────────┼──────────┼───────────┼─────────────┼───────┼──────────┼──────────────┼─────────────┼───────────── diff --git a/docs/sample_config/config.toml b/docs/sample_config/config.toml index 9ff26ef5b8..ab6412d303 100644 --- a/docs/sample_config/config.toml +++ b/docs/sample_config/config.toml @@ -3,7 +3,7 @@ header_align = "l" header_color = "c" header_bold = true nonzero_exit_errors = true -startup = ["alias la [path] {ls --full $path}", "alias nudown [] {fetch https://api.github.com/repos/nushell/nushell/releases | get assets | select name download_count}"] +startup = ["alias la [path] {ls --long $path}", "alias nudown [] {fetch https://api.github.com/repos/nushell/nushell/releases | get assets | select name download_count}"] table_mode = "other" plugin_dirs = ["D:\\Src\\GitHub\\nu-plugin-lib\\samples\\Nu.Plugin.Len\\bin\\Debug\\netcoreapp3.1"] pivot_mode = "auto" @@ -44,4 +44,4 @@ theme = "TwoDark" # To add path and env do this # > config set path $nu.path -# > config set env $nu.env \ No newline at end of file +# > config set env $nu.env