fix(core): update

This commit is contained in:
2022-08-03 17:07:11 +02:00
parent f7c24a0bd2
commit db1e866fe1
6 changed files with 28 additions and 58 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartcli',
version: '4.0.0',
version: '4.0.1',
description: 'easy observable cli tasks'
}

View File

@ -16,8 +16,7 @@ export class Smartcli {
* this Deferred contains the parsed result in the end
*/
public parseCompleted = plugins.smartpromise.defer<any>();
public version: string;
private checkForEnvCliCall = true;
@ -29,7 +28,7 @@ export class Smartcli {
/**
* maps alias
*/
public aliasObject: {[key: string]: string[]} = {};
public aliasObject: { [key: string]: string[] } = {};
/**
* The constructor of Smartcli
@ -46,7 +45,7 @@ export class Smartcli {
/**
* adds an alias, meaning one equals the other in terms of command execution.
*/
public addCommandAlias(originalArg, aliasArg): void {
public addCommandAlias(originalArg: string, aliasArg: string): void {
this.aliasObject[originalArg] = this.aliasObject[originalArg] || [];
this.aliasObject[originalArg].push(aliasArg);
}
@ -58,12 +57,12 @@ export class Smartcli {
public addCommand(commandNameArg: string): plugins.smartrx.rxjs.Subject<any> {
let commandSubject: plugins.smartrx.rxjs.Subject<any>;
const existingCommandSubject = this.getCommandSubject(commandNameArg);
commandSubject = existingCommandSubject || new plugins.smartrx.rxjs.Subject<any>();
commandSubject = existingCommandSubject || new plugins.smartrx.rxjs.Subject<any>();
this.commandObservableMap.add({
commandName: commandNameArg,
subject: commandSubject,
})
});
return commandSubject;
}
@ -105,7 +104,7 @@ export class Smartcli {
public addVersion(versionArg: string) {
this.version = versionArg;
this.addCommandAlias('v', 'version');
this.parseCompleted.promise.then(argv => {
this.parseCompleted.promise.then((argv) => {
if (argv.v) {
console.log(this.version);
}
@ -132,12 +131,12 @@ export class Smartcli {
return;
}
const parsedYArgs = plugins.yargsParser(process.argv);
// lets handle commands
let counter = 0;
let foundCommand = false;
parsedYArgs._.map((commandPartArg) => {
counter ++;
counter++;
if (typeof commandPartArg === 'number') {
return true;
}
@ -148,17 +147,17 @@ export class Smartcli {
} else {
return true;
}
})
});
for (const command of this.commandObservableMap.getArray()) {
if (!parsedYArgs._[0]) {
const standardCommand = this.commandObservableMap.findSync(commandArg => {
return commandArg.commandName === "standardCommand";
const standardCommand = this.commandObservableMap.findSync((commandArg) => {
return commandArg.commandName === 'standardCommand';
});
if (standardCommand) {
standardCommand.subject.next(parsedYArgs);
} else {
console.log('no smartcli standard task was created or assigned.');
};
}
break;
}
if (command.commandName === parsedYArgs._[0]) {
@ -166,7 +165,6 @@ export class Smartcli {
break;
}
if (this.aliasObject[parsedYArgs[0]]) {
}
}
this.parseCompleted.resolve(parsedYArgs);

View File

@ -11,6 +11,4 @@ export { smartlog, lik, path, smartparam, smartpromise, smartrx };
// thirdparty scope
import yargsParser from 'yargs-parser';
export {
yargsParser
}
export { yargsParser };