@extrahorizon/exh-cli 1.12.0-dev-138-3fed4c5 → 1.12.0-dev-139-711ee70
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.
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handler = exports.builder = exports.desc = exports.command = void 0;
|
|
4
4
|
const chalk = require("chalk");
|
|
5
|
-
const exh_1 = require("../../exh");
|
|
6
5
|
const util_1 = require("../../helpers/util");
|
|
6
|
+
const templateRepository = require("../../repositories/templates");
|
|
7
7
|
exports.command = 'get';
|
|
8
8
|
exports.desc = 'Fetch a template';
|
|
9
9
|
const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
@@ -23,16 +23,17 @@ const builder = (yargs) => (0, util_1.epilogue)(yargs).options({
|
|
|
23
23
|
});
|
|
24
24
|
exports.builder = builder;
|
|
25
25
|
const handler = async function list({ name, id }) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.log(chalk.red('Failed to get template!'));
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
console.log(JSON.stringify(template, null, 4));
|
|
26
|
+
let template;
|
|
27
|
+
if (name) {
|
|
28
|
+
template = await templateRepository.findByName(name);
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
else if (id) {
|
|
31
|
+
template = await templateRepository.findById(id);
|
|
36
32
|
}
|
|
33
|
+
if (!template) {
|
|
34
|
+
console.log(chalk.red('Failed to get template!'));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
console.log(JSON.stringify(template, null, 4));
|
|
37
38
|
};
|
|
38
39
|
exports.handler = handler;
|