forked from extern/nushell
Ensure that command usage starts uppercase and ends period (#11278)
# Description This repeats #8268 to make all command usage strings start with an uppercase letter and end with a period per #5056 Adds a test to ensure that commands won't regress Part of #5066 # User-Facing Changes Command usage is now consistent # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting Automatic documentation updates
This commit is contained in:
@ -57,7 +57,7 @@ impl Command for BytesAt {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Get bytes defined by a range"
|
||||
"Get bytes defined by a range."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -54,7 +54,7 @@ impl Command for Join {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Join two tables"
|
||||
"Join two tables."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -23,7 +23,7 @@ impl Command for SplitBy {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Split a record into groups"
|
||||
"Split a record into groups."
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -24,7 +24,7 @@ impl<D: HashDigest> Default for GenericDigest<D> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: format!("hash {}", D::name()),
|
||||
usage: format!("Hash a value using the {} hash algorithm", D::name()),
|
||||
usage: format!("Hash a value using the {} hash algorithm.", D::name()),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ impl Command for InputListen {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Listen for user interface event"
|
||||
"Listen for user interface event."
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
|
@ -23,7 +23,7 @@ impl Command for IsTerminal {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Check if stdin, stdout, or stderr is a terminal"
|
||||
"Check if stdin, stdout, or stderr is a terminal."
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
|
@ -27,7 +27,7 @@ impl Command for SubCommand {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Removed command: use `format date` instead"
|
||||
"Removed command: use `format date` instead."
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -35,7 +35,7 @@ impl Command for StorCreate {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Create a table in the in-memory sqlite database"
|
||||
"Create a table in the in-memory sqlite database."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -35,7 +35,7 @@ impl Command for StorDelete {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Delete a table or specified rows in the in-memory sqlite database"
|
||||
"Delete a table or specified rows in the in-memory sqlite database."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -29,7 +29,7 @@ impl Command for StorExport {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Export the in-memory sqlite database to a sqlite database file"
|
||||
"Export the in-memory sqlite database to a sqlite database file."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -29,7 +29,7 @@ impl Command for StorImport {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Import a sqlite database file into the in-memory sqlite database"
|
||||
"Import a sqlite database file into the in-memory sqlite database."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -35,7 +35,7 @@ impl Command for StorInsert {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Insert information into a specified table in the in-memory sqlite database"
|
||||
"Insert information into a specified table in the in-memory sqlite database."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -24,7 +24,7 @@ impl Command for StorOpen {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Opens the in-memory sqlite database"
|
||||
"Opens the in-memory sqlite database."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -21,7 +21,7 @@ impl Command for StorReset {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Reset the in-memory database by dropping all tables"
|
||||
"Reset the in-memory database by dropping all tables."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -41,7 +41,7 @@ impl Command for StorUpdate {
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Update information in a specified table in the in-memory sqlite database"
|
||||
"Update information in a specified table in the in-memory sqlite database."
|
||||
}
|
||||
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
|
@ -110,3 +110,52 @@ fn no_search_term_duplicates() {
|
||||
failures.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn usage_end_period() {
|
||||
let ctx = crate::create_default_context();
|
||||
let decls = ctx.get_decls_sorted(true);
|
||||
let mut failures = Vec::new();
|
||||
|
||||
for (name_bytes, decl_id) in decls {
|
||||
let cmd = ctx.get_decl(decl_id);
|
||||
let cmd_name = String::from_utf8_lossy(&name_bytes);
|
||||
let usage = cmd.usage();
|
||||
|
||||
if !usage.ends_with('.') {
|
||||
failures.push(format!("{cmd_name}: \"{usage}\""));
|
||||
}
|
||||
}
|
||||
|
||||
assert!(
|
||||
failures.is_empty(),
|
||||
"Command usage does not end with a period:\n{}",
|
||||
failures.join("\n")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn usage_start_uppercase() {
|
||||
let ctx = crate::create_default_context();
|
||||
let decls = ctx.get_decls_sorted(true);
|
||||
let mut failures = Vec::new();
|
||||
|
||||
for (name_bytes, decl_id) in decls {
|
||||
let cmd = ctx.get_decl(decl_id);
|
||||
let cmd_name = String::from_utf8_lossy(&name_bytes);
|
||||
let usage = cmd.usage();
|
||||
|
||||
// Check lowercase to allow usage to contain removed syntax like:
|
||||
//
|
||||
// "`let-env FOO = ...` …"
|
||||
if usage.starts_with(|u: char| u.is_lowercase()) {
|
||||
failures.push(format!("{cmd_name}: \"{usage}\""));
|
||||
}
|
||||
}
|
||||
|
||||
assert!(
|
||||
failures.is_empty(),
|
||||
"Command usage does not start with an uppercase letter:\n{}",
|
||||
failures.join("\n")
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user