@rockset/cli
Version:
Official Rockset CLI
48 lines (47 loc) • 2.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const core_2 = require("@rockset/core");
const base_command_1 = require("../../../base-command");
const chalk = require("chalk");
let AddEntity = /** @class */ (() => {
class AddEntity extends base_command_1.RockCommand {
async run() {
const { args, flags } = await this.parse(AddEntity);
// Will throw for invalid qualified name
const qualifiedName = core_2.types.parseLambdaQualifiedName(args.name);
const srcPath = await core_2.fileutil.getSrcPath();
const lambda = await core_2.pathutil.resolvePathFromQualifiedName(qualifiedName, 'lambda', srcPath);
const lambdaExists = await core_2.fileutil.exists(lambda);
if (lambdaExists) {
this.error(`${qualifiedName} already exists.`);
}
const entity = await core_2.types.createEmptyQLEntity(qualifiedName, flags === null || flags === void 0 ? void 0 : flags.description);
await core_2.fileutil.writeLambda(entity);
this.log(chalk `Successfully added Query Lambda {green ${qualifiedName}} to path {green ${lambda}}`);
}
}
AddEntity.flags = {
help: core_1.Flags.help({ char: 'h' }),
description: core_1.Flags.string({
char: 'd',
description: 'set the description for the Query Lambda',
}),
};
AddEntity.args = [
{
name: 'name',
required: true,
hidden: false,
description: 'the fully qualified name of the lambda you wish to add (eg. "{workspace}.{name}") ',
},
];
AddEntity.examples = [
` $ rockset local:queryLambda:add commons.helloWorld -d "my lambda"
Successfully added Query Lambda commons.helloWorld to path /Users/tchordia/rockset/src/commons/helloWorld.lambda.json
`,
];
AddEntity.description = `add a Query Lambda to the current project`;
return AddEntity;
})();
exports.default = AddEntity;