-
Notifications
You must be signed in to change notification settings - Fork 0
/
carryall-cli.js
executable file
·49 lines (39 loc) · 1.47 KB
/
carryall-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
#!/usr/bin/env node
"use strict";
const Carryall = require("./lib/core/Carryall");
const fs = require("fs");
const program = require("commander");
const ownVersion = require("./package.json");
const parseConfig = (program, defaultReporter) => {
const config = JSON.parse(fs.readFileSync(program.config || "./carryall.json", { "encoding": "UTF-8" }));
config.reporter.mode = program.reporter || defaultReporter;
config.control = {
silent: !!program.silent,
noRestart: !program.restart,
verbose: !!program.verbose
}
return config;
}
program
.version(ownVersion.version)
.option("-c", "--config <path>", "Change the configuration file. Defaults to carryall.json");
program
.command("deploy")
.description("Updates the environment installation to match versions in the descriptor")
.option("--reporter <reporter>", "Which reporter to use [cli|slack|combined]. Defaults to combined")
.option("-s, --silent", "Silent mode, will not prompt for any action")
.option("-R, --no-restart", "Do not perform a service restart")
.option("-v, --verbose", "Verbose mode")
.action(program => {
const config = parseConfig(program, "combined");
new Carryall().deploy(config)
});
program
.command("list")
.description("Query the current state of the environment")
.option("--reporter <reporter>", "Which reporter to use [cli|slack|combined]. Defaults to cli")
.action(program => {
const config = parseConfig(program, "cli");
new Carryall().state(config)
});
program.parse(process.argv)