diff options
| author | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-03-25 20:59:29 +0900 | 
|---|---|---|
| committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2020-03-25 20:59:29 +0900 | 
| commit | 70b08f1025d3e00a016843669d61c56789bc0028 (patch) | |
| tree | e1f99494016a0b13894f1e739f1ff87102c4fd13 /src/shared/Command.ts | |
| parent | 7d51364584e9081f71f4691a713bb737f7573a74 (diff) | |
Complete commands on the console script
Diffstat (limited to 'src/shared/Command.ts')
| -rw-r--r-- | src/shared/Command.ts | 29 | 
1 files changed, 29 insertions, 0 deletions
diff --git a/src/shared/Command.ts b/src/shared/Command.ts index e492f4a..b8c21ce 100644 --- a/src/shared/Command.ts +++ b/src/shared/Command.ts @@ -13,3 +13,32 @@ export enum Command {      Set = "set",      Help = "help",  } + +export namespace Command { +  export function members(): Command[] { +    return [ +      Command.Open , +      Command.TabOpen , +      Command.WindowOpen , +      Command.Buffer , +      Command.BufferDelete , +      Command.BufferDeleteForce , +      Command.BuffersDelete , +      Command.BuffersDeleteForce , +      Command.AddBookmark , +      Command.Quit , +      Command.QuitAll , +      Command.Set , +      Command.Help , +    ] +  } + +  export function valueOf(value: string): Command { +    const map = new Map(members().map(cmd => [cmd.toString(), cmd])); +    const cmd = map.get(value); +    if (!cmd) { +      throw new Error(`unknown command '${value}`); +    } +    return cmd; +  } +}  | 
