Commit 10acc6b3 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

add basic option parsing

parent a2e2c50c
Loading
Loading
Loading
Loading
+39 −15
Original line number Diff line number Diff line
@@ -6,10 +6,37 @@ use utf8;

our $VERSION = '0.00';

use Getopt::Long;
use List::Util qw(min);
use Travel::Status::DE::IRIS;
use Travel::Status::DE::DBWagenreihung;

my $developer_mode = 0;

sub show_help {
	my ($code) = @_;

	say "Usage: db-wagenreihung <station> <train number>";

	exit $code;
}

sub show_version {
	say "db-wagenreihung version ${VERSION}";

	exit 0;
}

GetOptions(
	'h|help'  => sub { show_help(0) },
	'devmode' => \$developer_mode,
	'version' => sub { show_version() },
) or show_help(1);

if ( @ARGV != 2 ) {
	show_help(1);
}

my ( $station, $train_number ) = @ARGV;

my $col_first  = "\e[38;5;11m";
@@ -18,6 +45,7 @@ my $col_second = "\e[38;5;9m";
my $col_reset  = "\e[0m";

my $res = Travel::Status::DE::IRIS->new(
	developer_mode => $developer_mode,
	station        => $station,
	with_related   => 1
);
@@ -36,7 +64,7 @@ if ( @trains != 1 ) {

my $wr = Travel::Status::DE::DBWagenreihung->new(
	departure      => $trains[0]->sched_departure,
	developer_mode => 1,
	developer_mode => $developer_mode,
	train_number   => $train_number,
);

@@ -87,11 +115,7 @@ for my $wagon ( $wr->wagons ) {
	}

	printf( "%s%s%3s%s%s",
		' ' x $spacing_left,
		$class_color,
		$wagon_desc,
		$col_reset,
		' ' x $spacing_right
	);
		' ' x $spacing_left, $class_color, $wagon_desc,
		$col_reset,          ' ' x $spacing_right );
}
print "\n";