-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·98 lines (87 loc) · 2.41 KB
/
cli.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
#!/usr/bin/env node
/**
* Description: Main entrypoint of program,
* defines all commands you can do with compozen
* Author: Kasey Martin
* Email: kasey.hackspace@gmail.com
*/
const compozen_cli = require('commander');
const {
compozenUp,
compozenDown,
importRecipe,
spinupRecipe,
addIngredient,
modIngredient,
delIngredient } = require('./lib/compozen');
compozen_cli
.version('0.0.1')
.description('CLI tool to generate and manage docker-compose.yml files');
compozen_cli
.command('up')
.alias('u')
.description('start compozen\'s redis server')
.action(
() => {
compozenUp();
}
);
compozen_cli
.command('down')
.alias('d')
.description('stop compozen\'s redis server')
.action(
() => {
compozenDown();
}
);
compozen_cli
.command('import-recipe <recipe_name> <recipe_file>')
.alias('i')
.description('import a YAML or JSON encoded docker-compose recipe')
.action(
(recipe_name, recipe_file) => {
importRecipe({recipe_name, recipe_file});
}
);
compozen_cli
.command('spinup-recipe <recipe_name>')
.alias('s')
.description('export recipe to a valid docker-compose.yml file')
.option('-o, --out <out_directory>')
.action(
(recipe_name, cmd) => {
spinupRecipe({recipe_name, cmd});
}
);
compozen_cli
.command('add-ingredient <recipe_name> <service_file>')
.alias('ai')
.description('import a YAML or JSON encoded docker-compose service into a recipe')
.action(
(recipe_name, service_file) => {
addIngredient({recipe_name, service_file});
}
);
compozen_cli
.command('mod-ingredient <recipe_name> <service_name> <service_file>')
.alias('mi')
.description('modify a service in a recipe with a YAML or JSON encoded docker-compose service')
.action(
(recipe_name, service_name, service_file) => {
modIngredient({recipe_name, service_name, service_file});
}
);
compozen_cli
.command('del-ingredient <recipe_name> <service_name>')
.alias('di')
.description('delete a service from a recipe')
.action(
(recipe_name, service_name) => {
delIngredient({recipe_name, service_name});
}
);
compozen_cli.parse(process.argv);
if(compozen_cli.args.length === 0){
compozen_cli.help();
}