aboutsummaryrefslogtreecommitdiff
path: root/src/console/commandline
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-05-02 17:25:56 +0900
committerGitHub <noreply@github.com>2020-05-02 17:25:56 +0900
commit5df0537bcf65a341e79852b1b30379c73318529c (patch)
treeaee5efe52412855f620cb514a13a2c14373f27b7 /src/console/commandline
parent685f2b7b69218b06b5bb676069e35f79c5048c9b (diff)
parent75abd90ecb8201ad845b266f96220d8adfe19b2d (diff)
Merge pull request #749 from ueokande/qa-0.28
QA 0.28
Diffstat (limited to 'src/console/commandline')
-rw-r--r--src/console/commandline/CommandLineParser.ts12
-rw-r--r--src/console/commandline/CommandParser.ts74
2 files changed, 43 insertions, 43 deletions
diff --git a/src/console/commandline/CommandLineParser.ts b/src/console/commandline/CommandLineParser.ts
index a166f49..ffff375 100644
--- a/src/console/commandline/CommandLineParser.ts
+++ b/src/console/commandline/CommandLineParser.ts
@@ -2,9 +2,9 @@ import CommandParser from "./CommandParser";
import { Command } from "../../shared/Command";
export type CommandLine = {
- readonly command: Command,
- readonly args: string
-}
+ readonly command: Command;
+ readonly args: string;
+};
export enum InputPhase {
OnCommand,
@@ -17,11 +17,11 @@ export default class CommandLineParser {
inputPhase(line: string): InputPhase {
line = line.trimLeft();
if (line.length == 0) {
- return InputPhase.OnCommand
+ return InputPhase.OnCommand;
}
const command = line.split(/\s+/, 1)[0];
if (line.length == command.length) {
- return InputPhase.OnCommand
+ return InputPhase.OnCommand;
}
return InputPhase.OnArgs;
}
@@ -33,6 +33,6 @@ export default class CommandLineParser {
return {
command: this.commandParser.parse(command),
args: args,
- }
+ };
}
}
diff --git a/src/console/commandline/CommandParser.ts b/src/console/commandline/CommandParser.ts
index 5228c77..7488cbc 100644
--- a/src/console/commandline/CommandParser.ts
+++ b/src/console/commandline/CommandParser.ts
@@ -9,43 +9,43 @@ export class UnknownCommandError extends Error {
export default class CommandParser {
parse(value: string): Command {
switch (value) {
- case 'o':
- case 'open':
- return Command.Open;
- case 't':
- case 'tabopen':
- return Command.TabOpen;
- case 'w':
- case 'winopen':
- return Command.WindowOpen;
- case 'b':
- case 'buffer':
- return Command.Buffer;
- case 'bd':
- case 'bdel':
- case 'bdelete':
- return Command.BufferDelete;
- case 'bd!':
- case 'bdel!':
- case 'bdelete!':
- return Command.BufferDeleteForce;
- case 'bdeletes':
- return Command.BuffersDelete;
- case 'bdeletes!':
- return Command.BuffersDeleteForce;
- case 'addbookmark':
- return Command.AddBookmark;
- case 'q':
- case 'quit':
- return Command.Quit;
- case 'qa':
- case 'quitall':
- return Command.QuitAll;
- case 'set':
- return Command.Set;
- case 'h':
- case 'help':
- return Command.Help;
+ case "o":
+ case "open":
+ return Command.Open;
+ case "t":
+ case "tabopen":
+ return Command.TabOpen;
+ case "w":
+ case "winopen":
+ return Command.WindowOpen;
+ case "b":
+ case "buffer":
+ return Command.Buffer;
+ case "bd":
+ case "bdel":
+ case "bdelete":
+ return Command.BufferDelete;
+ case "bd!":
+ case "bdel!":
+ case "bdelete!":
+ return Command.BufferDeleteForce;
+ case "bdeletes":
+ return Command.BuffersDelete;
+ case "bdeletes!":
+ return Command.BuffersDeleteForce;
+ case "addbookmark":
+ return Command.AddBookmark;
+ case "q":
+ case "quit":
+ return Command.Quit;
+ case "qa":
+ case "quitall":
+ return Command.QuitAll;
+ case "set":
+ return Command.Set;
+ case "h":
+ case "help":
+ return Command.Help;
}
throw new UnknownCommandError(value);
}