Skip to content
Snippets Groups Projects
Select Git revision
  • 4db9ee9e6127f6ad525794e8d3f984bfa45f4c09
  • main default protected
  • jw_sonar
  • v6.0.0 protected
  • interactive-mode-preference
  • bedran_exercise-list
  • add_route_user
  • Jw_sonar_backup
  • exercise_list_filter
  • assignment_filter
  • add_route_assignments
  • move-to-esm-only
  • 6.0.0-dev
  • Pre-alpha
  • 5.0.0
  • Latest
  • 4.2.0
  • 4.1.1
  • 4.1.0
  • 4.0.1
  • 4.0.0
  • 3.5.0
  • 3.4.2
  • 3.4.1
  • 3.3.0
  • 3.2.3
  • 3.2.2
  • 3.2.0
  • 3.1.2
  • 3.1.1
  • 3.1.0
  • 3.0.1
32 results

CommanderCommand.ts

Blame
  • CommanderCommand.ts 791 B
    import { Command, CommandOptions } from 'commander';
    
    
    abstract class CommanderCommand {
        protected abstract commandName: string;
        protected aliasNames: Array<string> = [];
    
        protected options: CommandOptions = {};
    
        command: Command = new Command();
    
        registerOnCommand(parent: Command) {
            this.command = parent.command(this.commandName, this.options).aliases(this.aliasNames);
    
            this.defineCommand();
            this.defineSubCommands();
        }
    
        protected abstract defineCommand(): void;
    
        protected defineSubCommands() {
            /*
            * No action
            * Override this method only if you need to define subcommands
            * */
        }
    
        protected abstract commandAction(...args: Array<unknown>): Promise<void>;
    }
    
    
    export default CommanderCommand;