-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
60 lines (59 loc) · 1.21 KB
/
index.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env node
const yargs = require("yargs");
const { checkout } = require("./src/checkout");
const { init } = require("./src/init");
const { add } = require("./src/add");
const { commit } = require("./src/commit");
yargs
.scriptName("gitjs-parser")
.usage("$0 <cmd> [args]")
.command(
"checkout [branch]",
"Checkout a branch",
(yargs) => {
yargs.positional("branch", {
describe: "Branch to checkout",
type: "string",
});
},
(argv) => {
console.log("checkout", argv.branch);
checkout(argv.branch);
},
)
.command("init [folder]", "Initialize a new git repository", {}, (argv) => {
yargs.positional("folder", {
describe: "Folder to initialize",
type: "string",
default: ".",
});
console.log("init", argv.folder);
init(argv.folder);
})
.command(
"add [files..]",
"Add files to the staging area",
(yargs) => {
yargs.required("files", {
describe: "Files to add",
type: "array",
});
},
(argv) => {
add(argv.files);
},
)
.command(
"commit [message]",
"Commit changes",
(yargs) => {
yargs.positional("message", {
describe: "Commit message",
type: "string",
});
},
(argv) => {
commit(argv.message);
},
)
.help().argv;