Skip to content
Snippets Groups Projects
Select Git revision
  • 9668ab1b140309a5aa724ab3c1ee3ede5cc1820a
  • 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

CommanderApp.ts

Blame
  • CommanderApp.ts 1.26 KiB
    import { Command }         from 'commander';
    import SessionCommand      from './session/SessionCommand';
    import ClientsSharedConfig from '../sharedByClients/config/ClientsSharedConfig';
    import AssignmentCommand   from './assignment/AssignmentCommand';
    import ExerciseCommand     from './exercise/ExerciseCommand';
    
    
    class CommanderApp {
        program: Command = new Command();
    
        constructor() {
            this.program
            .name('dojo')
            .description('CLI of the Dojo application')
            .version('DEV')
            .showHelpAfterError()
            .configureHelp({
                               showGlobalOptions: true,
                               sortOptions      : true,
                               sortSubcommands  : true
                           })
            .option('-H, --host <string>', 'override the Dojo API endpoint', ClientsSharedConfig.apiURL);
    
            this.program.on('option:host', () => {
                ClientsSharedConfig.apiURL = this.program.opts().host;
            });
    
            this.registerCommands();
    
            this.program.parse();
        }
    
        private registerCommands() {
            SessionCommand.registerOnCommand(this.program);
            AssignmentCommand.registerOnCommand(this.program);
            ExerciseCommand.registerOnCommand(this.program);
        }
    }
    
    
    export default CommanderApp;