Add long options for path (#10775)

This commit is contained in:
Hofer-Julian
2023-10-19 22:07:01 +02:00
committed by GitHub
parent 4fd2b702ee
commit 11480c77be
8 changed files with 27 additions and 26 deletions

View File

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

View File

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

View File

@ -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![