| 1 | package App::financeta; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use 5.10.0; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use App::financeta::utils qw(dumper log_filter); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use Log::Any '$log', filter => \&App::financeta::utils::log_filter; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Log::Any::Adapter 'Stderr'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 0 | ▶ | use App::financeta::gui; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 9 | |||
| 10 | our $VERSION = '0.16'; | ||
| 11 | $VERSION = eval $VERSION; | ||
| 12 | |||
| 13 | sub print_banner { | ||
| 14 | my $pkg = shift || __PACKAGE__; | ||
| 15 | my $this_year = (gmtime)[5] + 1900; | ||
| 16 | my $license = <<"LICENSE"; | ||
| 17 | $pkg Copyright (C) 2013-$this_year Vikas N Kumar <vikas\@cpan.org> | ||
| 18 | This program comes with ABSOLUTELY NO WARRANTY; for details read the LICENSE | ||
| 19 | file in the distribution.This is free software, and you are welcome to | ||
| 20 | redistribute it under certain conditions. The developers are not responsible | ||
| 21 | for any profits or losses incurred due to the use of this software. Use at your own | ||
| 22 | risk and with your own intelligence. | ||
| 23 | LICENSE | ||
| 24 | print STDERR $license, "\n"; | ||
| 25 | return; | ||
| 26 | } | ||
| 27 | |||
| 28 | sub get_version { return $VERSION; } | ||
| 29 | |||
| 30 | sub print_version_and_exit { | ||
| 31 | die __PACKAGE__ . " Version $VERSION\n"; | ||
| 32 | } | ||
| 33 | |||
| 34 | sub run { | ||
| 35 | my @args = @_; | ||
| 36 | shift @args if (@args and ($args[0] eq __PACKAGE__ or ref($args[0]) eq __PACKAGE__)); | ||
| 37 | my %opts = @args; | ||
| 38 | delete $opts{help}; | ||
| 39 | delete $opts{version}; | ||
| 40 | my $log_level; | ||
| 41 | $opts{verbose} //= 0; | ||
| 42 | if ($opts{verbose} >= 3) { | ||
| 43 | $log_level = 'trace'; | ||
| 44 | } elsif ($opts{verbose} eq 2 or $opts{debug}) { | ||
| 45 | $log_level = 'debug'; | ||
| 46 | } elsif ($opts{quiet} or $opts{verbose} eq 0) { | ||
| 47 | $log_level = 'warn'; | ||
| 48 | } else { | ||
| 49 | $log_level = 'info'; | ||
| 50 | } | ||
| 51 | delete $opts{quiet}; | ||
| 52 | Log::Any::Adapter->set('Stderr', log_level => $log_level); | ||
| 53 | $log->debug("Options sent to the Gui: " . dumper(\%opts)); | ||
| 54 | $log->debug("Setting log level to $log_level"); | ||
| 55 | my $gui = App::financeta::gui->new( | ||
| 56 | log_level => $log_level, | ||
| 57 | debug => $opts{debug}, | ||
| 58 | brand => __PACKAGE__, | ||
| 59 | plot_engine => $opts{plot_engine} // 'highcharts', | ||
| 60 | ); | ||
| 61 | return $gui->run; | ||
| 62 | } | ||
| 63 | |||
| 64 | 1; | ||
| 65 | __END__ | ||