mirror of
https://github.com/nushell/nushell.git
synced 2024-11-21 16:03:19 +01:00
Add long options for path (#10775)
This commit is contained in:
parent
4fd2b702ee
commit
11480c77be
@ -110,7 +110,7 @@ impl Command for SubCommand {
|
||||
},
|
||||
Example {
|
||||
description: "Replace basename of a path",
|
||||
example: "'C:\\Users\\joe\\test.txt' | path basename -r 'spam.png'",
|
||||
example: "'C:\\Users\\joe\\test.txt' | path basename --replace 'spam.png'",
|
||||
result: Some(Value::test_string("C:\\Users\\joe\\spam.png")),
|
||||
},
|
||||
]
|
||||
@ -134,7 +134,7 @@ impl Command for SubCommand {
|
||||
},
|
||||
Example {
|
||||
description: "Replace basename of a path",
|
||||
example: "'/home/joe/test.txt' | path basename -r 'spam.png'",
|
||||
example: "'/home/joe/test.txt' | path basename --replace 'spam.png'",
|
||||
result: Some(Value::test_string("/home/joe/spam.png")),
|
||||
},
|
||||
]
|
||||
|
@ -120,13 +120,13 @@ impl Command for SubCommand {
|
||||
},
|
||||
Example {
|
||||
description: "Walk up two levels",
|
||||
example: "'C:\\Users\\joe\\code\\test.txt' | path dirname -n 2",
|
||||
example: "'C:\\Users\\joe\\code\\test.txt' | path dirname --num-levels 2",
|
||||
result: Some(Value::test_string("C:\\Users\\joe")),
|
||||
},
|
||||
Example {
|
||||
description: "Replace the part that would be returned with a custom path",
|
||||
example:
|
||||
"'C:\\Users\\joe\\code\\test.txt' | path dirname -n 2 -r C:\\Users\\viking",
|
||||
"'C:\\Users\\joe\\code\\test.txt' | path dirname --num-levels 2 --replace C:\\Users\\viking",
|
||||
result: Some(Value::test_string("C:\\Users\\viking\\code\\test.txt")),
|
||||
},
|
||||
]
|
||||
@ -150,12 +150,13 @@ impl Command for SubCommand {
|
||||
},
|
||||
Example {
|
||||
description: "Walk up two levels",
|
||||
example: "'/home/joe/code/test.txt' | path dirname -n 2",
|
||||
example: "'/home/joe/code/test.txt' | path dirname --num-levels 2",
|
||||
result: Some(Value::test_string("/home/joe")),
|
||||
},
|
||||
Example {
|
||||
description: "Replace the part that would be returned with a custom path",
|
||||
example: "'/home/joe/code/test.txt' | path dirname -n 2 -r /home/viking",
|
||||
example:
|
||||
"'/home/joe/code/test.txt' | path dirname --num-levels 2 --replace /home/viking",
|
||||
result: Some(Value::test_string("/home/viking/code/test.txt")),
|
||||
},
|
||||
]
|
||||
|
@ -118,12 +118,12 @@ On Windows, an extra 'prefix' column is added."#
|
||||
},
|
||||
Example {
|
||||
description: "Replace a complex extension",
|
||||
example: r"'C:\Users\viking\spam.tar.gz' | path parse -e tar.gz | upsert extension { 'txt' }",
|
||||
example: r"'C:\Users\viking\spam.tar.gz' | path parse --extension tar.gz | upsert extension { 'txt' }",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Ignore the extension",
|
||||
example: r"'C:\Users\viking.d' | path parse -e ''",
|
||||
example: r"'C:\Users\viking.d' | path parse --extension ''",
|
||||
result: Some(Value::test_record(Record {
|
||||
cols: vec![
|
||||
"prefix".into(),
|
||||
@ -193,12 +193,12 @@ On Windows, an extra 'prefix' column is added."#
|
||||
},
|
||||
Example {
|
||||
description: "Replace a complex extension",
|
||||
example: r"'/home/viking/spam.tar.gz' | path parse -e tar.gz | upsert extension { 'txt' }",
|
||||
example: r"'/home/viking/spam.tar.gz' | path parse --extension tar.gz | upsert extension { 'txt' }",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Ignore the extension",
|
||||
example: r"'/etc/conf.d' | path parse -e ''",
|
||||
example: r"'/etc/conf.d' | path parse --extension ''",
|
||||
result: Some(Value::test_record(Record {
|
||||
cols: vec!["parent".into(), "stem".into(), "extension".into()],
|
||||
vals: vec![
|
||||
|
@ -21,7 +21,7 @@ fn replaces_basename_of_empty_input() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path basename -r newname.txt
|
||||
| path basename --replace newname.txt
|
||||
"#
|
||||
));
|
||||
|
||||
@ -47,7 +47,7 @@ fn replaces_basename_of_path_ending_with_dot() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/."
|
||||
| path basename -r viking.txt
|
||||
| path basename --replace viking.txt
|
||||
"#
|
||||
));
|
||||
|
||||
@ -74,7 +74,7 @@ fn replaces_basename_of_path_ending_with_double_dot() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/file.txt/.."
|
||||
| path basename -r eggs
|
||||
| path basename --replace eggs
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -21,7 +21,7 @@ fn replaces_dirname_of_empty_input() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo ""
|
||||
| path dirname -r newdir
|
||||
| path dirname --replace newdir
|
||||
"#
|
||||
));
|
||||
|
||||
@ -47,7 +47,7 @@ fn replaces_dirname_of_path_ending_with_dot() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/."
|
||||
| path dirname -r eggs
|
||||
| path dirname --replace eggs
|
||||
"#
|
||||
));
|
||||
|
||||
@ -74,7 +74,7 @@ fn replaces_dirname_of_path_with_double_dot() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/.."
|
||||
| path dirname -r eggs
|
||||
| path dirname --replace eggs
|
||||
"#
|
||||
));
|
||||
|
||||
@ -88,7 +88,7 @@ fn returns_dirname_of_zero_levels() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -n 0
|
||||
| path dirname --num-levels 0
|
||||
"#
|
||||
));
|
||||
|
||||
@ -101,7 +101,7 @@ fn replaces_dirname_of_zero_levels_with_empty_string() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -n 0 -r ""
|
||||
| path dirname --num-levels 0 --replace ""
|
||||
"#
|
||||
));
|
||||
|
||||
@ -114,7 +114,7 @@ fn replaces_dirname_of_more_levels() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -r eggs -n 2
|
||||
| path dirname --replace eggs -n 2
|
||||
"#
|
||||
));
|
||||
|
||||
@ -128,7 +128,7 @@ fn replaces_dirname_of_way_too_many_levels() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo "some/dir/with/spam.txt"
|
||||
| path dirname -r eggs -n 999
|
||||
| path dirname --replace eggs -n 999
|
||||
"#
|
||||
));
|
||||
|
||||
|
@ -49,7 +49,7 @@ fn parses_custom_extension_gets_extension() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo 'home/viking/spam.tar.gz'
|
||||
| path parse -e tar.gz
|
||||
| path parse --extension tar.gz
|
||||
| get extension
|
||||
"#
|
||||
));
|
||||
@ -63,7 +63,7 @@ fn parses_custom_extension_gets_stem() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo 'home/viking/spam.tar.gz'
|
||||
| path parse -e tar.gz
|
||||
| path parse --extension tar.gz
|
||||
| get stem
|
||||
"#
|
||||
));
|
||||
@ -77,7 +77,7 @@ fn parses_ignoring_extension_gets_extension() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo 'home/viking/spam.tar.gz'
|
||||
| path parse -e ''
|
||||
| path parse --extension ''
|
||||
| get extension
|
||||
"#
|
||||
));
|
||||
@ -91,7 +91,7 @@ fn parses_ignoring_extension_gets_stem() {
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo 'home/viking/spam.tar.gz'
|
||||
| path parse -e ""
|
||||
| path parse --extension ""
|
||||
| get stem
|
||||
"#
|
||||
));
|
||||
|
@ -6,7 +6,7 @@ print '-------------------------------------------------------------------'
|
||||
|
||||
warning "./scripts/build-all.nu will be deprecated, please use the `toolkit build` command instead"
|
||||
|
||||
let repo_root = ($env.CURRENT_FILE | path dirname -n 2)
|
||||
let repo_root = ($env.CURRENT_FILE | path dirname --num-levels 2)
|
||||
|
||||
def build-nushell [] {
|
||||
print $'(char nl)Building nushell'
|
||||
|
@ -4,7 +4,7 @@ use std log warning
|
||||
warning "./scripts/coverage-local.nu will be deprecated, please use the `toolkit cov` command instead"
|
||||
|
||||
def compute-coverage [] {
|
||||
cd ($env.CURRENT_FILE | path dirname -n 2)
|
||||
cd ($env.CURRENT_FILE | path dirname --num-levels 2)
|
||||
|
||||
print "Setting up environment variables for coverage"
|
||||
# Enable LLVM coverage tracking through environment variables
|
||||
|
Loading…
Reference in New Issue
Block a user