kodilist
Version:
CLI tool for generating Kodi playlists based on filename-embedded tags.
48 lines (47 loc) • 1.7 kB
TypeScript
import { ConfigFile } from ".";
/**
* An OperationSet contains a function for each action the user can take,
* nested nicely to represent possible paths. The first term passed on the
* command line can be any of the top-level values; the second term passed can
* be any values nested beneath that.
*/
export interface OperationSet {
[key: string]: any;
generate: () => void;
list: {
people: () => void;
directories: () => void;
tags: () => void;
sources: () => void;
ignores: () => void;
};
delete: {
person: () => void;
ignore: () => void;
directory: () => void;
tag: () => void;
source: () => void;
};
ignore: () => void;
add: {
person: () => void;
tag: () => void;
source: () => void;
directory: () => void;
};
}
/**
* Produces an OperationSet object that can be used to easily match the command
* line input to the desired function. The first term passed to kodilist selects
* a top-level key in the OperationSet. If the first term matched a function,
* all further terms become its arguments; if the first term matched an object,
* the second term selects a function and terms 3+ become its arguments.
*
* For example, `$ kodilist add source bbc.co.uk` matches
* `['add']['source']['bbc.co.uk']()`.
*
* Arguments do not need to be directly passed to the matched function; the
* full string is passed in when `Operations()` is invoked and each function
* selects the portion it needs.
*/
export default function Operations(config: ConfigFile, paramSet: string[]): OperationSet;