From 70b08f1025d3e00a016843669d61c56789bc0028 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Wed, 25 Mar 2020 20:59:29 +0900 Subject: Complete commands on the console script --- src/shared/Command.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/shared') 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; + } +} -- cgit v1.2.3