Change help strings to const
This commit is contained in:
parent
e6e52ddb58
commit
cb256f0ce4
2 changed files with 10 additions and 13 deletions
17
src/help.rs
17
src/help.rs
|
@ -1,16 +1,15 @@
|
||||||
/// Standard help string containing usage information for MPS.
|
/// Standard help string containing usage information for MPS.
|
||||||
pub fn help() -> String {
|
pub const HELP_STRING: &str =
|
||||||
"This language is all about iteration. Almost everything is an iterator or operates on iterators. By default, any operation which is not an assignment will cause the script runner to handle (play/save) the items which that statement contains.
|
"This language is all about iteration. Almost everything is an iterator or operates on iterators. By default, any operation which is not an assignment will cause the script runner to handle (play/save) the items which that statement contains.
|
||||||
|
|
||||||
To view the currently-supported operations, try ?functions and ?filters".to_string()
|
To view the currently-supported operations, try ?functions and ?filters";
|
||||||
}
|
|
||||||
|
|
||||||
pub fn functions() -> String {
|
pub const FUNCTIONS: &str =
|
||||||
"FUNCTIONS (?functions)
|
"FUNCTIONS (?functions)
|
||||||
Similar to most other languages: function_name(param1, param2, etc.)
|
Similar to most other languages: function_name(param1, param2, etc.)
|
||||||
|
|
||||||
sql_init(generate = true|false, folder = `path/to/music`)
|
sql_init(generate = true|false, folder = `path/to/music`)
|
||||||
Initialize the SQLite database connection using the provided parameters. This must be performed before any other database operation (otherwise the database will be connected with default settings).
|
Initialize the SQLite database connection using the provided parameters. This must be performed before any other database operation (otherwise the database will already be connected with default settings).
|
||||||
|
|
||||||
sql(`SQL query here`)
|
sql(`SQL query here`)
|
||||||
Perform a raw SQLite query on the database which MPS auto-generates. An iterator of the results is returned.
|
Perform a raw SQLite query on the database which MPS auto-generates. An iterator of the results is returned.
|
||||||
|
@ -31,10 +30,9 @@ Similar to most other languages: function_name(param1, param2, etc.)
|
||||||
Repeat the iterable count times, or infinite times if count is omitted.
|
Repeat the iterable count times, or infinite times if count is omitted.
|
||||||
|
|
||||||
files(folder = `path/to/music`, recursive = true|false, regex = `pattern`)
|
files(folder = `path/to/music`, recursive = true|false, regex = `pattern`)
|
||||||
Retrieve all files from a folder, matching a regex pattern.".to_string()
|
Retrieve all files from a folder, matching a regex pattern.";
|
||||||
}
|
|
||||||
|
|
||||||
pub fn filters() -> String {
|
pub const FILTERS: &str =
|
||||||
"FILTERS (?filters)
|
"FILTERS (?filters)
|
||||||
Operations to reduce the items in an iterable: iterable.(filter)
|
Operations to reduce the items in an iterable: iterable.(filter)
|
||||||
|
|
||||||
|
@ -46,5 +44,4 @@ Operations to reduce the items in an iterable: iterable.(filter)
|
||||||
Compare all items, keeping only those that match the condition.
|
Compare all items, keeping only those that match the condition.
|
||||||
|
|
||||||
[empty]
|
[empty]
|
||||||
Matches all items".to_string()
|
Matches all items";
|
||||||
}
|
|
||||||
|
|
|
@ -111,9 +111,9 @@ fn prompt(line: &mut usize, args: &CliArgs) {
|
||||||
fn repl_commands(command_str: &str) {
|
fn repl_commands(command_str: &str) {
|
||||||
let words: Vec<&str> = command_str.split(" ").map(|s| s.trim()).collect();
|
let words: Vec<&str> = command_str.split(" ").map(|s| s.trim()).collect();
|
||||||
match words[0] {
|
match words[0] {
|
||||||
"?help" => println!("{}", super::help::help()),
|
"?help" => println!("{}", super::help::HELP_STRING),
|
||||||
"?function" | "?functions" => println!("{}", super::help::functions()),
|
"?function" | "?functions" => println!("{}", super::help::FUNCTIONS),
|
||||||
"?filter" | "?filters" => println!("{}", super::help::filters()),
|
"?filter" | "?filters" => println!("{}", super::help::FILTERS),
|
||||||
_ => println!("Unknown command, try ?help"),
|
_ => println!("Unknown command, try ?help"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue