#!/usr/bin/env node /** * Command line interface of apeman. * This file is auto generated by ape-tmpl. */ 'use strict' const program = require('commander') const pkg = require('../package') const apeman = require('../lib') program .version(pkg[ 'version' ]) .description('Meta application framework.') // Handling `api` command program .command('api') .description('') .option('-p, --port ', 'Port number') .option('-c, --configuration ', 'Pathname of Apemanfile') .action((options) => apeman.api(options).catch(handleError) ) // Handling `doc` command program .command('doc') .description('Generate project documentation.') .option('-o, --out ', 'Output directory path.') .option('-c, --configuration ', 'Pathname of Apemanfile') .option('-C, --context ', 'Pathname of mock context file.') .action((options) => apeman.doc(options).catch(handleError) ) // Handling `init` command program .command('init') .description('Initialize a directory as an apeman project.') .option('-f, --force', 'Force to init.') .option('-d, --dirname ', 'Directory name to init.') .option('-s, --silent', 'Disable console logs') .option('-p, --pkg ', 'Path of package.json') .action((options) => apeman.init(options).catch(handleError) ) // Handling `need` command program .command('need') .description('Check project needs.') .option('-c, --configuration ', 'Pathname of Apemanfile') .action((options) => apeman.need(options).catch(handleError) ) // Handling `scff` command program .command('scff [type] [dest]') .description('Generate project scaffold.') .option('-t, --straight', 'Scaffold without asking.') .option('-s, --silent', 'Disable console logs') .option('-f, --force', 'Force to generate scaffold') .action((type, dest, options) => apeman.scff(type, dest, options).catch(handleError) ) // Handling `srch` command program .command('srch [term...]') .description('Search apeman modules.') .option('-v, --verbose', 'Show verbose logs') .option('-t, --type ', 'Type to search.') .action((term, options) => apeman.srch(term, options).catch(handleError) ) // Handling `show` command program .command('show [keypath...]') .description('Show apemanfile configuration.') .option('-c, --configuration ', 'Pathname of Apemanfile') .option('-k, --keysonly', 'Show keys only') .action((keypath, options) => apeman.show(keypath, options).catch(handleError) ) // Handling `tree` command program .command('tree') .description('Show project inheritance in the tree.') .option('-c, --configuration ', 'Pathname of Apemanfile') .action((options) => apeman.tree(options).catch(handleError) ) // Handling `upg` command program .command('upg') .description('Update apeman global module.') .option('-v, --verbose', 'Show verbose logs') .action((options) => apeman.upg(options).catch(handleError) ) program.parse(process.argv) // Check sub command { let command = process.argv[2] if (!command) { program.outputHelp() return } let _isValid = name => { for (let command of program.commands) { let hit = (command.name() == name) || (command.alias() == name) if(hit){ return true } } return false } if (!_isValid(command)) { console.log("[apeman] '%s' is not an apeman command. See 'apeman --help'.", command) } } // Handlers /** Handle error */ function handleError (err) { console.error(err) process.exit(1) }