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
This commit is contained in:
Joseph T. Lyons 2020-08-01 14:30:45 -04:00 committed by GitHub
parent 4ef15b5f80
commit 9fb6f5cd09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 34 additions and 33 deletions

View File

@ -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,
},
]

View File

@ -45,7 +45,7 @@ impl WholeStreamCommand for Default {
fn examples(&self) -> Vec<Example> {
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,
}]
}

View File

@ -11,7 +11,7 @@ pub struct Ls;
pub struct LsArgs {
pub path: Option<Tagged<PathBuf>>,
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'),
)
}

View File

@ -37,7 +37,7 @@ pub(crate) fn dir_entry_dict(
filename: &std::path::Path,
metadata: Option<&std::fs::Metadata>,
tag: impl Into<Tag>,
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));
}

View File

@ -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,

View File

@ -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"
);
},
);

View File

@ -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<String>,

View File

@ -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<Vec<ReturnValue>, 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())

View File

@ -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<Vec<Value>, ShellError> {
pub async fn ps(tag: Tag, long: bool) -> Result<Vec<Value>, ShellError> {
let processes = process::processes()
.await
.map_err(|_| {
@ -67,7 +67,7 @@ pub async fn ps(tag: Tag, full: bool) -> Result<Vec<Value>, ShellError> {
"virtual",
UntaggedValue::filesize(memory.vms().get::<information::byte>()),
);
if full {
if long {
if let Ok(parent_pid) = process.parent_pid().await {
dict.insert_untagged("parent", UntaggedValue::int(parent_pid))
}

View File

@ -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
───┼─────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────

View File

@ -12,6 +12,6 @@ Displays the last 100 commands.
...
97 │ date
98 │ ls
99 │ ls -fa
99 │ ls -la
─────┴────────────────────────────────────────────────────────────────────────
```

View File

@ -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
───┼────────────────────┼──────┼────────┼──────────┼───────────┼─────────────┼───────┼──────────┼──────────────┼─────────────┼─────────────

View File

@ -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"