import * as program from 'commander'; import i18n from '../utils/i18n'; // import * as msg from './init-message'; import { InitManager } from './init-manager'; import { CommandError } from '../error/command-error'; const description = `${i18n.__('Initialize a new project based on a template.')} ${i18n.__('Example:')} $ s init $ s init project $ s init git@github.com:foo/bar.git $ s init https://github.com/foo/bar.git`; program .name('s init') .helpOption('-h, --help', i18n.__('Display help for command')) .usage('[options] [name | url]') .option('-p, --provider [provider]', i18n.__('The cloud service provider')) .option('-d, --dir [dir]', i18n.__('Where to output the initialized app into (default: ./ )')) .description(description) .parse(process.argv); (async () => { if (program.args.length === 0) { program.help(); return; // throw new ServerlessError(msg.initPopUpTips); } const initManager = new InitManager(); const target = program.args[0]; const provider = program.provider; const dir = program.dir; await initManager.init(target, provider, dir); })().catch((err) => { throw new CommandError(err.message); });