@podge/cli 0.2.0-beta.8 → 0.2.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/collections.js +23 -0
- package/dist/commands/environments.js +22 -0
- package/dist/index.js +4 -2
- package/package.json +1 -1
|
@@ -49,6 +49,29 @@ function registerCollectionCommands(program) {
|
|
|
49
49
|
(0, client_1.handleError)(err);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
|
+
col
|
|
53
|
+
.command("create")
|
|
54
|
+
.description("Create a collection")
|
|
55
|
+
.requiredOption("--name <name>", "Collection name")
|
|
56
|
+
.requiredOption("--key <key>", "Collection key")
|
|
57
|
+
.option("-w, --workspace <key>", "Workspace key")
|
|
58
|
+
.option("-e, --environment <key>", "Environment key")
|
|
59
|
+
.option("--json", "Output as JSON")
|
|
60
|
+
.action(async (opts) => {
|
|
61
|
+
try {
|
|
62
|
+
const { ws, env } = requireContext(opts);
|
|
63
|
+
const { data } = await (0, client_1.getClient)().post(`/v1/workspace/${ws}/environment/${env}/collections`, { name: opts.name, key: opts.key });
|
|
64
|
+
if (opts.json) {
|
|
65
|
+
(0, output_1.printJson)(data);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
(0, output_1.printSuccess)(`Collection "${opts.name}" created (key: ${opts.key})`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
(0, client_1.handleError)(err);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
52
75
|
col
|
|
53
76
|
.command("get <key>")
|
|
54
77
|
.description("Get collection details")
|
|
@@ -46,6 +46,28 @@ function registerEnvironmentCommands(program) {
|
|
|
46
46
|
(0, client_1.handleError)(err);
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
+
env
|
|
50
|
+
.command("create")
|
|
51
|
+
.description("Create an environment")
|
|
52
|
+
.requiredOption("--name <name>", "Environment name")
|
|
53
|
+
.requiredOption("--key <key>", "Environment key")
|
|
54
|
+
.option("-w, --workspace <key>", "Workspace key")
|
|
55
|
+
.option("--json", "Output as JSON")
|
|
56
|
+
.action(async (opts) => {
|
|
57
|
+
try {
|
|
58
|
+
const ws = requireWorkspace(opts);
|
|
59
|
+
const { data } = await (0, client_1.getClient)().post(`/v1/workspace/${ws}/environments`, { name: opts.name, key: opts.key });
|
|
60
|
+
if (opts.json) {
|
|
61
|
+
(0, output_1.printJson)(data);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
(0, output_1.printSuccess)(`Environment "${opts.name}" created (key: ${opts.key})`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
(0, client_1.handleError)(err);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
49
71
|
env
|
|
50
72
|
.command("get <key>")
|
|
51
73
|
.description("Get environment details")
|
package/dist/index.js
CHANGED
|
@@ -31,9 +31,11 @@ function showBanner() {
|
|
|
31
31
|
console.log(dim(` v${pkg.version}`));
|
|
32
32
|
console.log("");
|
|
33
33
|
}
|
|
34
|
-
// Show banner when run with no args or
|
|
34
|
+
// Show banner when run with no args, top-level --help, or auth commands
|
|
35
35
|
const args = process.argv.slice(2);
|
|
36
|
-
|
|
36
|
+
const isTopLevelHelp = args.length === 0 ||
|
|
37
|
+
(args.length === 1 && (args[0] === "--help" || args[0] === "-h"));
|
|
38
|
+
if (isTopLevelHelp || args[0] === "auth") {
|
|
37
39
|
showBanner();
|
|
38
40
|
}
|
|
39
41
|
const program = new commander_1.Command();
|