App-Chart
view release on metacpan or search on metacpan
['-v, --version', __('Print Chart version')],
['--verbose', __('Print extra messages')],
['--download', __('Download data for selected symbols, don\'t run the GUI')],
['--ticker', __('Run just the stock ticker, on selected symbols')],
['--all', __('Select all symbols')],
['--alerts', __('Select alerts list symbols')],
['--favourites', __('Select favourites list symbols')],
['--display=DPY',
__("X display to use (default DISPLAY environment variable)")],
['--<gtk-options>', __('Standard Gtk options')]);
my $width = 2 + max (map { length ($_->[0]) } @opts);
foreach (@opts) {
printf "%-*s%s\n", $width, $_->[0], $_->[1];
}
print "\n";
print __"When running the GUI, the SYMBOL argument is an initial chart to show\n(can be a partial match, as in the open dialog).\n";
print __"When running download or ticker, the SYMBOL... arguments select specific\nsymbols to show or download (must be full symbols, no partial matches).\n";
exit 0;
};
GetOptions (require_order => 1,
'help|?' => $help,
version => sub {
print "chart version $App::Chart::VERSION\n";
exit 0;
},
all => $add_symlist,
favourites => $add_symlist,
favorites => $add_symlist,
historical => $add_symlist,
alerts => $add_symlist,
'<>' => sub { my ($value) = @_;
# stringize to avoid Getopt::Long object
push @args, "$value";
},
download => $set_mode,
ticker => $set_mode,
watchlist => $set_mode,
subprocess => $set_mode, # undocumented
emacs => $set_mode, # undocumented
vacuum => $set_mode, # undocumented yet
'verbose:i' => sub {
my ($opt, $value) = @_;
if ($value==0) {
$App::Chart::option{'verbose'}++;
} else {
$App::Chart::option{'verbose'} = $value;
}
},
'all-status' => $set_output, # undocumented
'lwp-debug' => sub {
require LWP::Debug;
LWP::Debug::level('+');
},
)
or exit 1;
}
# $filename is in filesystem charset bytes.
#
# The file should end with some non-undef value, since otherwise it's
# indistinguishable from undef for the various do/require errors.
#
sub initfile {
my ($filename) = @_;
if (! -e $filename) { return; }
$! = 0;
my $ret = do $filename;
if (! defined $ret) {
my $display_filename = Glib::filename_display_name($filename);
if ($@) {
my $err = $@;
unless (utf8::is_utf8($err)) { $err = Encode::decode('locale',$err); }
print __x("chart: error in {filename}\n{error}\n (starting anyway)\n",
filename => $display_filename,
error => $err);
} elsif ($! != 0) {
my $err = Glib::strerror($!);
print __x("chart: cannot read {filename}: {error}\n (starting anyway)\n",
filename => $display_filename,
error => $err);
} else {
print __x("chart: {filename} didn't end with a true value\n",
filename => $display_filename);
}
}
}
$option_mode ||= 'gui';
$option_output ||= 'tty';
unshift @INC, File::Spec->catdir (App::Chart::chart_directory(), 'lib');
initfile (File::Spec->catfile (App::Chart::chart_directory(), 'init.pl'));
if ($option_mode eq 'gui') {
# default is the gui
require App::Chart::Gtk2::Main;
App::Chart::Gtk2::Main->main (\@args);
} elsif ($option_mode eq 'download') {
require App::Chart::Download;
App::Chart::Download->command_line_download ($option_output, \@args);
} elsif ($option_mode eq 'subprocess') {
require App::Chart::SubprocessMain;
App::Chart::SubprocessMain->main ();
} elsif ($option_mode eq 'vacuum') {
require App::Chart::Vacuum;
App::Chart::Vacuum->command_line_vacuum ($option_output, \@args);
} elsif ($option_mode eq 'emacs') {
require App::Chart::EmacsMain;
App::Chart::EmacsMain->main ();
} elsif ($option_mode eq 'watchlist') {
require App::Chart::Gtk2::WatchlistDialog;
App::Chart::Gtk2::WatchlistDialog->main (\@args);
( run in 1.106 second using v1.01-cache-2.11-cpan-39bf76dae61 )