Skip to content

armgit / fli

Public Imported from GitHub
0

Google Flights MCP, CLI and Python Library

Update --stops to also accept number input

Punit Arani21cd5e480684
diff --git a/fli/cli/commands/cheap.py b/fli/cli/commands/cheap.py
index a6196d3..741eff2 100644
--- a/fli/cli/commands/cheap.py
+++ b/fli/cli/commands/cheap.py
@@ -4,12 +4,11 @@ import typer
from typing_extensions import Annotated
from fli.cli.enums import DayOfWeek
-from fli.cli.utils import display_date_results, filter_dates_by_days, validate_date
+from fli.cli.utils import display_date_results, filter_dates_by_days, parse_stops, validate_date
from fli.models import (
Airport,
DateSearchFilters,
FlightSegment,
- MaxStops,
PassengerInfo,
SeatType,
)
@@ -38,7 +37,7 @@ def cheap(
typer.Option(
"--stops",
"-x",
- help="Maximum number of stops (ANY, NON_STOP, ONE_STOP, TWO_PLUS_STOPS)",
+ help="Maximum number of stops (ANY, 0 for non-stop, 1 for one stop, 2+ for two stops)",
),
] = "ANY",
monday: Annotated[
@@ -113,7 +112,7 @@ def cheap(
departure_airport = getattr(Airport, from_airport.upper())
arrival_airport = getattr(Airport, to_airport.upper())
seat_type = getattr(SeatType, seat.upper())
- max_stops = getattr(MaxStops, stops.upper())
+ max_stops = parse_stops(stops)
# Create flight segment
flight_segment = FlightSegment(
diff --git a/fli/cli/commands/search.py b/fli/cli/commands/search.py
index 5f8f620..e36b5ae 100644
--- a/fli/cli/commands/search.py
+++ b/fli/cli/commands/search.py
@@ -8,10 +8,11 @@ from fli.cli.utils import (
filter_flights_by_airlines,
filter_flights_by_time,
parse_airlines,
+ parse_stops,
validate_date,
validate_time_range,
)
-from fli.models import Airport, MaxStops, PassengerInfo, SeatType, SortBy
+from fli.models import Airport, PassengerInfo, SeatType, SortBy
from fli.search import SearchFlights, SearchFlightsFilters
@@ -31,7 +32,7 @@ def search_flights(
departure_airport = getattr(Airport, from_airport.upper())
arrival_airport = getattr(Airport, to_airport.upper())
seat_type = getattr(SeatType, seat.upper())
- max_stops = getattr(MaxStops, stops.upper())
+ max_stops = parse_stops(stops)
sort_by = getattr(SortBy, sort.upper())
# Create search filters
@@ -105,7 +106,7 @@ def search(
typer.Option(
"--stops",
"-x",
- help="Maximum number of stops (ANY, NON_STOP, ONE_STOP, TWO_PLUS_STOPS)",
+ help="Maximum number of stops (ANY, 0 for non-stop, 1 for one stop, 2+ for two stops)",
),
] = "ANY",
sort: Annotated[