UNPKG

grapi-cli

Version:

a cli tool to generate loopback 4 applications with extra features like caching & fuzzy search

25 lines (24 loc) 1.22 kB
import { Command, Flags } from '@oclif/core'; import chalk from 'chalk'; import { processOptions, execute } from '../utils/index.js'; export default class SqlController extends Command { static description = 'describe the command here'; static flags = { config: Flags.string({ char: 'c', description: 'Config JSON object' }), query: Flags.string({ description: 'sql query to generate controller for' }), path: Flags.string({ description: 'path for endpoint' }), repoName: Flags.string({ description: 'repository name' }), appName: Flags.string({ description: 'name of the application' }), controllerName: Flags.string({ description: 'name of the generated controller' }), }; async run() { const parsed = await this.parse(SqlController); let options = processOptions(parsed.flags); options = JSON.stringify(options); const executed = await execute(`lb4-sql-controller --config='${options}'`, 'executing sql-controller'); if (executed.stderr) console.log(chalk.bold(chalk.green(executed.stderr))); if (executed.stdout) console.log(chalk.bold(chalk.green(executed.stdout))); } }