The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

CohortExplorer::Application - CohortExplorer superclass

SYNOPSIS

The class is inherited from CLI::Framework::Application and overrides the following methods:

usage_text()

This method returns the application usage.

option_spec()

This method returns the application option specifications as expected by Getopt::Long::Descriptive.

   ( 
     [ 'datasource|d:s' => 'provide datasource'           ],
     [ 'username|u:s'   => 'provide username'             ],
     [ 'password|p:s'   => 'provide password'             ],
     [ 'verbose|v'      => 'show with verbosity'          ],
     [ 'help|h'         => 'show usage message and exit'  ] 
   )

validate_options( $opts )

This method ensures the user has supplied all mandatory options such as datasource, username and password.

command_map()

This method returns the mapping between command names and command classes

  console  => 'CLI::Framework::Command::Console',
  help     => 'CohortExplorer::Command::Help',
  menu     => 'CohortExplorer::Command::Menu',
  describe => 'CohortExplorer::Command::Describe',
  history  => 'CohortExplorer::Command::History',
  find     => 'CohortExplorer::Command::Find',
  search   => 'CohortExplorer::Command::Query::Search',
  compare  => 'CohortExplorer::Command::Query::Compare'

command_alias()

This method returns mapping between command aliases and command names

  h    => 'help',
  m    => 'menu',
  s    => 'search',
  c    => 'compare',
  d    => 'describe',
  hist => 'history',
  f    => 'find',
  sh   => 'console'

pre_dispatch( $command )

This method ensures the invalid commands do not dispatch and logs all commands successfully dispatched.

noninteractive_commands()

The method returns a list of valid commands under interactive mode. The commands search, compare and history can be invalid because they are application dependent. These commands require the user to have access to at least one variable from the datasource and also depend on the datasource type. The compare command is only available to longitudinal datasources with data on at least 2 visits.

render( $output )

This method is responsible for the presentation of the command output. The output from all commands except help is organised into a table.

read_cmd( )

This method attempts to provide the autocompletion of options and arguments wherever applicable.

handle_exception( $e )

This method prints and logs exceptions.

init( $opts )

This method is responsible for the application initialization which includes prompting the user to enter password if not already supplied and initializing the logger and the datasource.

OPERATIONS

This class attempts to perform the following operations upon successful initialization of the datasource:

  1. Prints a menu of available commands based on the datasource type.

  2. Provides autocompletion of command arguments/options (if applicable) for the user entered command.

  3. Dispatches the command object for command specific processing.

  4. Logs exceptions (if any) thrown by the commands.

  5. In case of no exception, it captures the output returned by the command and displays in a table.

ERROR HANDLING

All exceptions thrown within CohortExplorer are treated by handle_exception( $e ). The exceptions are imported from CLI::Framework::Exceptions.

DEPENDENCIES

Carp

CLI::Framework::Application

CLI::Framework::Exceptions

Exception::Class::TryCatch

File::HomeDir

Log::Log4perl

Term::ReadKey

Text::ASCIITable

SEE ALSO

CohortExplorer

CohortExplorer::Datasource

CohortExplorer::Command::Describe

CohortExplorer::Command::Find

CohortExplorer::Command::Query::Search

CohortExplorer::Command::Query::Compare

LICENSE AND COPYRIGHT

Copyright (c) 2013-2014 Abhishek Dixit (adixit@cpan.org). All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of either:

  • the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version, or

  • the "Artistic Licence".

AUTHOR

Abhishek Dixit