Comparing version 2.0.0-rc.8 to 2.0.0-rc.9
@@ -16,7 +16,10 @@ /// <reference types="node" /> | ||
private readonly binaryName; | ||
private readonly version; | ||
private readonly registrations; | ||
constructor({ binaryName }?: { | ||
constructor({ binaryName, version }?: { | ||
binaryName?: string; | ||
version?: string; | ||
}); | ||
register(advancedCommand: CommandClass<Context>): void; | ||
private registerVersion; | ||
private registerGeneralHelp; | ||
@@ -23,0 +26,0 @@ private registerDefinitions; |
@@ -24,6 +24,8 @@ "use strict"; | ||
class Cli { | ||
constructor({ binaryName = `...` } = {}) { | ||
constructor({ binaryName = `...`, version = `no version specified` } = {}) { | ||
this.coreCli = new core.Cli(); | ||
this.registrations = []; | ||
this.binaryName = binaryName; | ||
this.version = version; | ||
this.registerVersion(); | ||
this.registerDefinitions(); | ||
@@ -37,2 +39,26 @@ this.registerGeneralHelp(); | ||
} | ||
registerVersion() { | ||
const self = this; | ||
class Version extends Command_1.Command { | ||
async execute() { | ||
this.context.stdout.write(`${self.version}\n`); | ||
} | ||
} | ||
__decorate([ | ||
Command_1.Command.HideFromErrors() | ||
], Version.prototype, "execute", null); | ||
const coreCommand = Version.compile(); | ||
// We replace the link function so that we can inject a special logic | ||
// into the state machine (instead of the default one which would check | ||
// the path, options, etc). | ||
coreCommand.link = function ({ proxyStart }) { | ||
if (typeof proxyStart === `undefined` || proxyStart >= 1) { | ||
const versionNode = this.createNode({ weight: 0, label: `activate the version` }); | ||
this.registerTransition(core.NODE_INITIAL, `-v`, versionNode); | ||
this.registerTransition(core.NODE_INITIAL, `--version`, versionNode); | ||
this.markTerminal(versionNode); | ||
} | ||
}; | ||
this.coreCli.register(coreCommand); | ||
} | ||
registerGeneralHelp() { | ||
@@ -39,0 +65,0 @@ const self = this; |
{ | ||
"name": "clipanion", | ||
"version": "2.0.0-rc.8", | ||
"version": "2.0.0-rc.9", | ||
"main": "lib/advanced", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
60998
1405