Skip to content

Commit

Permalink
refactor(command): remove DefaultCommand class (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed Jun 24, 2020
1 parent 7d5e318 commit 9e3913c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/command/lib/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import { IParseResult } from './types.ts';
*/
export class Command<O = any, A extends Array<any> = any> extends BaseCommand<O, A> {

#hasDefaults: Boolean = false;
private hasDefaults: Boolean = false;

public parse( args: string[] = Deno.args, dry?: boolean ): Promise<IParseResult<O, A>> {
this.#registerDefaults();
this.registerDefaults();
return super.parse( args, dry );
}

#registerDefaults = (): this => {
if ( this._parent || this.#hasDefaults ) {
private registerDefaults = (): this => {
if ( this.getParent() || this.hasDefaults ) {
return this;
}
this.#hasDefaults = true;
this.hasDefaults = true;
this.reset()
.option( '-h, --help', 'Show this help.', {
standalone: true,
Expand All @@ -37,7 +37,7 @@ export class Command<O = any, A extends Array<any> = any> extends BaseCommand<O,
.option( '-V, --version', 'Show the version number for this program.', {
standalone: true,
action: () => {
this.log( this.ver );
this.log( this.getVersion() );
Deno.exit( 0 );
}
} );
Expand Down

0 comments on commit 9e3913c

Please sign in to comment.