Document alias processing functions

This commit is contained in:
Isaac Khor 2018-01-09 00:41:32 +08:00
parent aff1ada83f
commit 4cf8c25cb8
No known key found for this signature in database
GPG key ID: D05A4A7EC9BCB5A9

View file

@ -4,6 +4,12 @@ export function commandIsAlias(command: string): boolean {
return Config.get("exaliases", command) !== undefined
}
/**
* Expands the alias in the provided exstr recursively. Does nothing if
* the command is not aliased, including when the command is invalid.
*
* @param exstr :exstr typed by the user on the commantd line
*/
export function expandExstr(exstr: string): string {
// Split on whitespace
const [command, ...args] = exstr.trim().split(/\s+/)
@ -14,6 +20,12 @@ export function expandExstr(exstr: string): string {
return expandedExstr
}
/**
* Expands the given command recursively. Does nothing if the command is not
* aliased, including when it is invalid.
*
* @param command The command portion of the exstr
*/
export function getAliasExpandRecur(command: string): string {
// Base case: alias not found; return original command
if(!commandIsAlias(command)) {