-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
43 lines (41 loc) · 1.54 KB
/
Copy pathhandler.js
File metadata and controls
43 lines (41 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const {
LoginUser,
RefactorStaged,
SelectComit,
GetCommitMessage,
} = require("./services");
const packageInfo = require("./package.json");
async function handleCommands(action) {
switch (true) {
case ["help"].includes(action):
console.log(
"Usage: comit [command]\n" +
"Commands:\n" +
" version, v, -v, --version : Display the current version of the application.\n" +
// " -b <arg> : Generate branch name using the given argument.\n" +
// " -c, c <arg> : Get a prompt response based on the given argument.\n" +
" login, -l, --login <token> : Login to the application.\n" +
// " -l, l, live, --live : Get a live prompt response.\n" +
" refactor, r, -r, --refactor : Run the refactor command.\n" +
" help, h, -h, --help : Show this help message."
);
return;
case ["v", "version", "-v", "--version"].includes(action):
console.log(packageInfo.version);
return;
case ["login", "-l", "--login"].includes(action):
LoginUser();
return;
case ["refactor", "r", "-r", "--refactor"].includes(action):
RefactorStaged();
return;
case [undefined].includes(action):
const commitMessages = await GetCommitMessage();
await SelectComit(commitMessages);
return;
default:
console.log("Invalid command run jcomit help for more information");
return;
}
}
module.exports = handleCommands;