2022-01-04 02:15:28 +00:00
/// Standard help string containing usage information for MPS.
2022-01-04 02:22:22 +00:00
pub const HELP_STRING : & str =
2022-01-04 02:15:28 +00:00
" 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.
2022-01-04 02:22:22 +00:00
To view the currently - supported operations , try ? functions and ? filters " ;
2022-01-04 02:15:28 +00:00
2022-01-04 02:22:22 +00:00
pub const FUNCTIONS : & str =
2022-01-04 02:15:28 +00:00
" FUNCTIONS (?functions)
Similar to most other languages : function_name ( param1 , param2 , etc . )
2022-01-18 14:14:05 +00:00
These always return an iterable which can me manipulated .
2022-01-04 02:15:28 +00:00
sql_init ( generate = true | false , folder = ` path / to / music ` )
2022-01-04 02:22:22 +00:00
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 ) .
2022-01-04 02:15:28 +00:00
sql ( ` SQL query here ` )
Perform a raw SQLite query on the database which MPS auto - generates . An iterator of the results is returned .
song ( ` something ` )
Retrieve all songs in the database with a title like something .
album ( ` something ` )
Retrieve all songs in the database with an album title like something .
artist ( ` something ` )
Retrieve all songs in the database with an artist name like something .
genre ( ` something ` )
Retrieve all songs in the database with a genre title like something .
repeat ( iterable , count )
Repeat the iterable count times , or infinite times if count is omitted .
files ( folder = ` path / to / music ` , recursive = true | false , regex = ` pattern ` )
2022-01-04 02:22:22 +00:00
Retrieve all files from a folder , matching a regex pattern . " ;
2022-01-04 02:15:28 +00:00
2022-01-04 02:22:22 +00:00
pub const FILTERS : & str =
2022-01-04 02:15:28 +00:00
" FILTERS (?filters)
Operations to reduce the items in an iterable : iterable . ( filter )
field = = something
2022-01-17 02:00:00 +00:00
field ! = something
2022-01-04 02:15:28 +00:00
field > = something
field > something
field < = something
2022-01-17 02:00:00 +00:00
field < something - - e . g . iterable . ( title = = ` Romantic Traffic ` )
Compare all items , keeping only those that match the condition . Valid field names are those of the MpsMusicItem ( title , artist , album , genre , track , etc . ) , though this will change when proper object support is added . Optionally , a ? or ! can be added to the end of the field name to skip items whose field is missing / incomparable , or keep all items whose field is missing / incomparable ( respectively ) .
2022-01-04 02:15:28 +00:00
2022-01-17 02:00:00 +00:00
start .. end - - e . g . iterable . ( 0 .. 42 )
Keep only the items that are at the start index up to the end index . Start and / or end may be omitted to start / stop at the iterable ' s existing start / end ( respectively ) . This stops once the end condition is met , leaving the rest of the iterator unconsumed .
start ..= end - - e . g . iterable . ( 0 ..= 42 )
Keep only the items that are at the start index up to and including the end index . Start may be omitted to start at the iterable ' s existing start . This stops once the end condition is met , leaving the rest of the iterator unconsumed .
index - - e . g . iterable . ( 4 )
Keep only the item at the given index . This stops once the index is reached , leaving the rest of the iterator unconsumed .
2022-01-17 02:48:32 +00:00
filter1 | | filter2 - - e . g . iterable . ( 4 | | 5 )
Keep only the items that meet the criteria of filter1 or filter2 . This will always consume the full iterator .
2022-01-17 02:00:00 +00:00
[ empty ] - - e . g . iterable . ( )
2022-01-18 14:14:05 +00:00
Matches all items
if filter : operation1 else operation2 - - e . g . iterable . ( if title = = ` Romantic Traffic ` : repeat ( item , 2 ) else item . ( ) )
Replace items matching the filter with operation1 and replace items not matching the filter with operation2 . The ` else operation2 ` part may be omitted to preserve items not matching the filter . To perform operations with the current item , use the special variable ` item ` . " ;