@grandlinex/easy-cli
Version:
Cli lib to perform common tasks
35 lines (34 loc) • 989 B
JavaScript
import { ShellCommand, } from '../../class/ShellComand.js';
import getVersion from '../../utils/Version.js';
export default class VersionAction extends ShellCommand {
constructor(props) {
super({
...props,
name: 'version',
description: 'Print the tool version',
properties: [
{
key: 'version',
type: 'null',
required: true,
},
{
key: 'stdout',
type: 'null',
required: false,
description: 'Print version to stdout instead of logger',
},
],
});
}
async run(parser) {
const param = parser.getParameters();
if (param.has('stdout')) {
console.log(`v${getVersion()}`);
}
else {
this.log(`v${getVersion()}`);
}
return true;
}
}