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 (i.e. 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 command alias
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 the commands dispatched by the users.
noninteractive_commands()
The method returns a list of the valid commands under interactive mode. The commands search, compare and history can be invalid as they are application dependent because they require the user to have access to at least one variable from the datasource and also depend on the datasource type.
render( $output )
This method is responsible for the presentation of the command output. All commands except help produce a tabular output.
read_cmd( )
This method attempts to provide the autocompletion of options and arguments wherever applicable.
handle_exception( $e )
This method prints and logs all exceptions.
init( $opts )
This method is responsible for the initialising of the application which includes initialising the logger and the datasource object.
OPERATIONS
This class attempts to perform the following operations upon successful initialisation of the datasource:
Prints a menu of available command based on the datasource type. For standard (i.e. non-longitudinal) datasource the command menu includes describe, find, search, history and help where as, the longitudinal datasources have also access to the compare command. The search, compare and history commands require the user to have access to at least one variable from the datasource. Steps 1 and 2 are skipped when the application is running in command-line mode.
Provides autocompletion of command arguments/options (if applicable) for the user entered command.
Dispatches the command object for command specific processing.
Logs exceptions (if any) thrown by the commands.
In case of no exceptions, it captures the output returned by the commands and displays them 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
SEE ALSO
CohortExplorer::Command::Describe
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