{"size": 988, "ext": "js", "max_stars_repo_path": "packages/tiga-crop/lib/command.js", "max_stars_repo_name": "Spencer17x/tiga", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/tiga-crop/lib/command.js", "max_issues_repo_name": "Spencer17x/tiga", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/tiga-crop/lib/command.js", "max_forks_repo_name": "Spencer17x/tiga", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.976744186, "max_line_length": 58, "alphanum_fraction": 0.6305668016}
const program = require('commander');
const pkg = require('../package.json');
const { askQuestions } = require('./question');
const { startPicCrop } = require('./crop');
const ora = require('ora');

program.version(pkg.version).usage('<command> [options]');

program
	.option('-u, --update', 'update to the latest version');

/**
 * 更新命令的版本
 */
program
	.command('update <version>')
	.description('update to the specified version')
	.action(version => {
		console.log(version, '这部分功能我也没写...待开发');
	});

/**
 * 将图片处理之后放到指定路径
 */
program
	.command('start')
	.description('star working on the image')
	.action(() => {
		let spinner;
		askQuestions().then(answers => {
			const { source, path, name, format } = answers;
			spinner = ora('开始处理...');
			spinner.start();
			return startPicCrop(path, `${name}.${format}`, source);
		}).then(() => {
			return spinner.succeed('处理成功');
		}).catch(err => {
			return spinner.fail(`处理失败：${err.toString()}`);
		});
	});


program.parse(process.argv);