@hyperone/cli-framework
Advanced tools
Comparing version 2.0.12 to 2.0.13
@@ -72,2 +72,8 @@ | ||
} | ||
async getOptions () { | ||
return [ | ||
{ name: 'command', defaultOption: true }, | ||
...await super.getOptions(), | ||
]; | ||
} | ||
async exec(argv = [], parentOpts = {}) { | ||
@@ -78,6 +84,3 @@ await this.loadCommands(); | ||
...commandLineArgs( | ||
[ | ||
{ name: 'command', defaultOption: true }, | ||
...this.options, | ||
], | ||
await this.getOptions(), | ||
{ argv, stopAtFirstUnknown: true } | ||
@@ -89,2 +92,5 @@ ), | ||
const cmd = this.commands.find(x => x.name == allOpts.command || x.aliases.includes(allOpts.command)); | ||
if (opts.version || allOpts.version) { | ||
return this.getVersion(); | ||
} | ||
if (!cmd) { | ||
@@ -91,0 +97,0 @@ if (allOpts.help) { |
@@ -46,2 +46,5 @@ | ||
} | ||
if (this.device && this.device.getVersion) { | ||
this.options.push({ name: 'version', alias: 'v', group: ['global'], type: Boolean, description: 'Show version and exit.' }); | ||
} | ||
return this.options.map(x => ({ | ||
@@ -90,3 +93,3 @@ ...x, | ||
content.push({ | ||
header: 'Global options', | ||
header: 'Common options', | ||
hide: ['command'], | ||
@@ -120,2 +123,5 @@ group: ['global'], | ||
} | ||
async getVersion() { | ||
return `${this.device.getName()} version ${this.device.getVersion()}`; | ||
} | ||
async exec(argv, parentOpts = {}) { | ||
@@ -131,2 +137,5 @@ const options = await this.getOptions(); | ||
} | ||
if (opts.version || allOpts.version) { | ||
return this.getVersion(); | ||
} | ||
if (opts._unknown && opts._unknown.length > 0) { | ||
@@ -133,0 +142,0 @@ const option = opts._unknown[0]; |
@@ -7,2 +7,5 @@ /* eslint-disable no-console */ | ||
} | ||
getVersion() { | ||
return require('./package.json').version; | ||
} | ||
async displayResult(result) { | ||
@@ -9,0 +12,0 @@ console.log(result); |
{ | ||
"name": "@hyperone/cli-framework", | ||
"version": "2.0.12", | ||
"version": "2.0.13", | ||
"description": "", | ||
@@ -20,3 +20,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "e22e39d7d1eb78f58a5a8fb2589ab7f825a04416" | ||
"gitHead": "9f7621663b4418ffaf570e6a0d025f4b73ec2626" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14314
416