diff options
Diffstat (limited to 'src/shared/Command.ts')
-rw-r--r-- | src/shared/Command.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/shared/Command.ts b/src/shared/Command.ts new file mode 100644 index 0000000..b8c21ce --- /dev/null +++ b/src/shared/Command.ts @@ -0,0 +1,44 @@ +export enum Command { + Open = "open", + TabOpen = "tabopen", + WindowOpen = "winopen", + Buffer = "buffer", + BufferDelete = "bdelete", + BufferDeleteForce = "bdelete!", + BuffersDelete = "bdeletes", + BuffersDeleteForce = "bdeletes!", + AddBookmark = "addbookmark", + Quit = "quit", + QuitAll = "quitall", + 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; + } +} |