// Error enhancements program .option( '--show-error-stack [json|string]', 'show JavaScript error stacks in the GraphQL result errors (recommended in development)', ) .option( '--extended-errors <string>', "a comma separated list of extended Postgres error fields to display in the GraphQL result. Recommended in development: 'hint,detail,errcode'. Default: none", (option: string) => option.split(',').filter(_ => _), );
it('should fail in action as port is invalid', done => { commander.loadDefinitions(testDefinitions); expect(() => { commander.parse(['node', './CLI.spec.js', '--arg0', 'arg0Value'], { PROGRAM_ARG_0: 'arg0ENVValue', PROGRAM_ARG_1: 'arg1ENVValue', PROGRAM_ARG_2: 'hello', }); }).toThrow('arg2 is invalid'); done(); });
program.on('--help', () => { console.log(` Get started: $ postgraphile $ postgraphile -c postgres://localhost/my_db $ postgraphile --connection postgres://user:pass@localhost/my_db --schema my_schema --watch --dynamic-json `); process.exit(0); });
program .command('generate') .option('-t, --tables <tables>', 'Comma delimited list of tables to generate schema from', list) .description('Generate Cube.js schema from DB tables schema') .action( (options) => generateSchema(options).catch(e => displayError(e.stack || e, { dbType: options.dbType })) ) .on('--help', () => { console.log(''); console.log('Examples:'); console.log(''); console.log(' $ cubejs generate -t orders,customers'); });
program.option("-s, --settings [settings]", "Overrides layout settings for given view types", (settings) => { const res = parseSettings(settings); if (res.error) { exitWithError(res.error); } return res.result; }, {} );
it('should load properly definitions from env', done => { commander.loadDefinitions(testDefinitions); commander.parse([], { PROGRAM_ARG_0: 'arg0ENVValue', PROGRAM_ARG_1: 'arg1ENVValue', PROGRAM_ARG_2: '3', }); expect(commander.arg0).toEqual('arg0ENVValue'); expect(commander.arg1).toEqual('arg1ENVValue'); expect(commander.arg2).toEqual(3); expect(commander.arg4).toEqual('arg4Value'); done(); });
function addFlag( optionString: string, description: string, parse?: (option: string) => mixed, ): AddFlagFn { program.option(optionString, description, parse); return addFlag; }
program .command('auth <token>') .description('Authenticate access to Cube Cloud') .action( (currentToken) => authenticate(currentToken) .catch(e => displayError(e.stack || e)) ) .on('--help', () => { console.log(''); console.log('Examples:'); console.log(''); console.log(' $ cubejs auth eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXBsb3ltZW50SWQiOiIxIiwidXJsIjoiaHR0cHM6Ly9leGFtcGxlcy5jdWJlY2xvdWQuZGV2IiwiaWF0IjoxNTE2MjM5MDIyfQ.La3MiuqfGigfzADl1wpxZ7jlb6dY60caezgqIOoHt-c'); console.log(' $ cubejs deploy'); });
program.on("--help", () => { console.log(""); console.log(" Examples:".blue); console.log(""); console.log(" $ xmysql -u username -p password -d databaseSchema".blue); console.log(""); });
program .command('deploy') .description('Deploy project to Cube Cloud') .action( (options) => deploy({ directory: process.cwd(), ...options }) .catch(e => displayError(e.stack || e)) ) .on('--help', () => { console.log(''); console.log('Examples:'); console.log(''); console.log(' $ cubejs deploy'); });
it('should fail when passing an invalid arguement', done => { commander.loadDefinitions(testDefinitions); expect(() => { commander.parse([ 'node', './CLI.spec.js', './spec/configs/CLIConfigUnknownArg.json', ]); }).toThrow('error: unknown option myArg'); done(); });
it('should fail when too many apps are set', done => { commander.loadDefinitions(testDefinitions); expect(() => { commander.parse([ 'node', './CLI.spec.js', './spec/configs/CLIConfigFailTooManyApps.json', ]); }).toThrow('Multiple apps are not supported'); done(); });