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

Support combining from/via/to place and name in a single argument

parent 385bc743
Loading
Loading
Loading
Loading
+17 −4
Changes for bin/efa: 17 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -36,7 +36,9 @@ my $output_reset = -t STDOUT ? "\033[0m" : q{};
sub show_help {
	my ($exit_status) = @_;

	say 'Usage: efa [options] <from-city> <from-stop> <to-city> <to-stop>';
	say
'Usage: efa [options] <from-city> <from-stop> [<via-city> <via-stop>] <to-city> <to-stop>';
	say '   or: efa [options] <from> [<via>] <to>';
	say 'See also: man efa';

	exit $exit_status;
@@ -112,7 +114,7 @@ sub handle_efa_exception {
	if ( $e->isa('Travel::Routing::DE::EFA::Exception::Ambiguous') ) {
		printf STDERR (
			"Backend error: The %s '%s' is ambiguous. Try one of %s\n",
			$e->post_key, $e->post_value,, $e->possibilities
			$e->post_key, $e->post_value, $e->possibilities
		);
		exit 4;
	}
@@ -432,7 +434,16 @@ elsif ( defined $ignore_info and length($ignore_info) == 0 ) {
}

if ( not( @from and @to ) ) {
	if ( @ARGV == 4 ) {
	if ( @ARGV == 2 ) {
		@from = ( undef, $ARGV[0] );
		@to   = ( undef, $ARGV[1] );
	}
	elsif ( @ARGV == 3 ) {
		@from = ( undef, $ARGV[0] );
		@via  = ( undef, $ARGV[1] );
		@to   = ( undef, $ARGV[2] );
	}
	elsif ( @ARGV == 4 ) {
		( @from[ 0, 1 ], @to[ 0, 1 ] ) = @ARGV;
	}
	elsif ( @ARGV == 6 ) {
@@ -515,10 +526,12 @@ efa - Command line client for EFA-based public transit routing services

=over

=item B<efa> B<--from> I<city> I<stop> B<--to> I<city> I<stop> [ I<additional options> ]
=item B<efa> [ I<options> ] I<from> [ I<via> ] I<to>

=item B<efa> [ I<options> ] I<from-city> I<from-stop> [ I<via-city> I<via-stop> ] I<to-city> I<to-stop>

=item B<efa> B<--from> I<city> I<stop> B<--to> I<city> I<stop> [ I<additional options> ]

=back

=head1 VERSION
+9 −3
Changes for lib/Travel/Routing/DE/EFA.pm: 9 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -292,16 +292,22 @@ sub with_wheelchair {
sub place {
	my ( $self, $which, $place, $stop, $type ) = @_;

	if ( not( $place and $stop ) ) {
	if ( not $stop ) {
		Travel::Routing::DE::EFA::Exception::Setup->throw(
			option => 'place',
			error  => 'Need >= three elements'
			error  => 'stop must be defined'
		);
	}

	$type //= 'stop';

	@{ $self->{post} }{ "place_${which}", "name_${which}" } = ( $place, $stop );
	if ($place) {
		@{ $self->{post} }{ "place_${which}", "name_${which}" }
		  = ( $place, $stop );
	}
	else {
		$self->{post}{"name_${which}"} = $stop;
	}

	if ( $type =~ m{ ^ (?: address | poi | stop ) $ }x ) {
		$self->{post}->{"type_${which}"} = $type;