-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
99 lines (87 loc) · 2.51 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /usr/bin/env node
const program = require('commander');
const lsCommand = require('./src/commands/lsCommand');
const stopCommand = require('./src/commands/stopCommand');
const startCommand = require('./src/commands/startCommand');
const backupCommand = require('./src/commands/dumpCommand');
const removeCommand = require('./src/commands/removeCommand');
const removeImageCommand = require('./src/commands/removeImageCommand');
const inspectCommand = require('./src/commands/inspectCommand');
const pullCommand = require('./src/commands/pullCommand');
const execCommand = require('./src/commands/execCommand');
const lessCommand = require('./src/commands/lessCommand');
program.version('1.0.8').description('CLI for Docker');
program
.option('-c, --container', 'List Containers')
.option('-i, --image', 'List Images')
.option('-v, --volume', 'List Volumes')
.action(obj => {
const { container, image, volume } = obj;
lsCommand(container, image, volume);
});
program
.command('cin')
.action(() => {
lessCommand();
});
program
.command('stop')
.option('-a, --all', 'Stops Containers')
.action(obj => {
const { all } = obj;
console.log(all);
stopCommand(all);
});
program
.command('start')
.option('-a, --all', 'Starts Containers')
.action(obj => {
const { all } = obj;
startCommand(all);
});
program
.command('rm')
.option('-v, --volume', 'Remove anonymous volumes associated with the container')
.option('-f, --force', 'Force the removal of a running container (uses SIGKILL)')
.action(obj => {
const { volume, force } = obj;
removeCommand(volume, force);
});
program
.command('rmi')
.option('-f, --force', 'Removes image that has associated with the container')
.action(obj => {
const { force } = obj;
console.log(`force is ${force}`);
if (force) {
removeImageCommand(force);
} else {
removeImageCommand();
}
});
program
.command('inspect')
.option('-j, --json', 'Creates json file of output of inspect log')
.option('-h, --host', 'Finds IPv4 address of container')
.action(obj => {
const { json, host } = obj;
inspectCommand(host, json);
});
program
.command('dump')
.option('-p, --postgre', 'Dump Postgre Database')
.option('-m, --mysql', 'Dump Mysql Database')
.action(obj => {
const { postgre, mysql } = obj;
backupCommand(postgre, mysql);
});
program
.command('pull')
.action(() => {
pullCommand();
});
program
.command('exec')
.action(() => {
});
program.parse(process.argv);