Skip to content

armgit / fli

Public Imported from GitHub
0

Google Flights MCP, CLI and Python Library

feat(cli): add --passengers option to flights, dates and multi (#210)

Hichame6884c660759
diff --git a/fli/cli/commands/dates.py b/fli/cli/commands/dates.py
index a66a6fa..2a71d91 100644
--- a/fli/cli/commands/dates.py
+++ b/fli/cli/commands/dates.py
@@ -254,6 +254,15 @@ def dates(
min=1,
),
] = None,
+ passengers: Annotated[
+ int,
+ typer.Option(
+ "--passengers",
+ "-p",
+ help="Number of adult passengers",
+ min=1,
+ ),
+ ] = 1,
):
"""Find the cheapest dates to fly between two airports.
@@ -306,6 +315,7 @@ def dates(
),
"sort_by_price": sort_by_price,
"days": [day.value for day in selected_days],
+ "passengers": passengers,
}
# Build time restrictions from tuple
@@ -343,7 +353,7 @@ def dates(
# Create search filters
filters = DateSearchFilters(
trip_type=trip_type,
- passenger_info=PassengerInfo(adults=1),
+ passenger_info=PassengerInfo(adults=passengers),
flight_segments=segments,
stops=stops,
seat_type=seat_type,
diff --git a/fli/cli/commands/flights.py b/fli/cli/commands/flights.py
index cd5eb74..d801af4 100644
--- a/fli/cli/commands/flights.py
+++ b/fli/cli/commands/flights.py
@@ -62,6 +62,7 @@ def _search_flights_core(
exclude_alliance: list[str] | None = None,
min_layover: int | None = None,
max_layover: int | None = None,
+ passengers: int = 1,
) -> None:
"""Core flight search functionality."""
query: dict[str, Any] = {
@@ -74,6 +75,7 @@ def _search_flights_core(
"cabin_class": cabin_class.upper(),
"max_stops": max_stops.upper(),
"sort_by": sort_by.upper(),
+ "passengers": passengers,
}
try:
@@ -158,7 +160,7 @@ def _search_flights_core(
# Create search filters
filters = FlightSearchFilters(
trip_type=trip_type,
- passenger_info=PassengerInfo(adults=1),
+ passenger_info=PassengerInfo(adults=passengers),
flight_segments=segments,
stops=stops,
seat_type=seat_type,
@@ -466,6 +468,15 @@ def flights(
min=1,
),
] = None,
+ passengers: Annotated[
+ int,
+ typer.Option(
+ "--passengers",
+ "-p",
+ help="Number of adult passengers",
+ min=1,
+ ),
+ ] = 1,
):
"""Search for flights on a specific date.
@@ -479,6 +490,7 @@ def flights(
fli flights JFK FRA 2026-10-25 --alliance ONEWORLD
fli flights JFK LAX 2026-10-25 --exclude-airlines DL
fli flights BUF ATH 2026-10-25 --min-layover 120
+ fli flights JFK LHR 2026-10-25 --passengers 2
"""
_search_flights_core(
@@ -506,4 +518,5 @@ def flights(
exclude_alliance=exclude_alliance,
min_layover=min_layover,
max_layover=max_layover,
+ passengers=passengers,
)
diff --git a/fli/cli/commands/multi.py b/fli/cli/commands/multi.py
index c76025f..2ae2d80 100644
--- a/fli/cli/commands/multi.py
+++ b/fli/cli/commands/multi.py
@@ -95,6 +95,15 @@ def multi(
help="Sort results by (CHEAPEST, DURATION, DEPARTURE_TIME, ARRIVAL_TIME)",
),
] = "CHEAPEST",
+ passengers: Annotated[
+ int,
+ typer.Option(
+ "--passengers",
+ "-p",
+ help="Number of adult passengers",
+ min=1,
+ ),
+ ] = 1,
):
"""Search for multi-city flights with multiple legs.
@@ -103,6 +112,7 @@ def multi(
Example:
fli multi --leg SEA,HKG,2026-12-26 --leg PEK,SEA,2027-01-02
fli multi -l SEA,NRT,2026-12-26 -l NRT,HKG,2026-12-30 -l HKG,SEA,2027-01-05 -c BUSINESS
+ fli multi -l SEA,NRT,2026-12-26 -l HKG,SEA,2027-01-05 --passengers 2
"""
try:
@@ -142,7 +152,7 @@ def multi(
# Create search filters
filters = FlightSearchFilters(
trip_type=trip_type,
- passenger_info=PassengerInfo(adults=1),
+ passenger_info=PassengerInfo(adults=passengers),
flight_segments=segments,
stops=stops,
seat_type=seat_type,
diff --git a/tests/cli/test_dates.py b/tests/cli/test_dates.py
index 202ad7c..fce404a 100644
--- a/tests/cli/test_dates.py
+++ b/tests/cli/test_dates.py
@@ -33,6 +33,17 @@ def test_basic_dates_search(runner, mock_search_dates, mock_console):
assert args[0].trip_type == TripType.ONE_WAY
+def test_dates_with_passengers(runner, mock_search_dates, mock_console):
+ """Test dates search passes adult passenger count into filters."""
+ mock_search_dates.search.return_value = []
+ result = runner.invoke(app, ["dates", "JFK", "LAX", "--passengers", "2", "--format", "json"])
+ assert result.exit_code == 0
+ args, _ = mock_search_dates.search.call_args
+ assert args[0].passenger_info.adults == 2
+ payload = json.loads(result.stdout)
+ assert payload["query"]["passengers"] == 2
+
+
def test_dates_with_date_range(runner, mock_search_dates, mock_console):
"""Test dates search with custom date range."""
from_date = datetime.now().strftime("%Y-%m-%d")
diff --git a/tests/cli/test_flights.py b/tests/cli/test_flights.py
index 7235075..affbea3 100644
--- a/tests/cli/test_flights.py
+++ b/tests/cli/test_flights.py
@@ -41,6 +41,44 @@ def test_flights_with_time_filter(runner, mock_search_flights, mock_console):
mock_search_flights.search.assert_called_once()
+def test_flights_with_passengers(runner, mock_search_flights, mock_console):
+ """Test flights search passes adult passenger count into filters."""
+ result = runner.invoke(
+ app,
+ [
+ "flights",
+ "JFK",
+ "LAX",
+ datetime.now().strftime("%Y-%m-%d"),
+ "--passengers",
+ "2",
+ ],
+ )
+ assert result.exit_code == 0
+ args, _ = mock_search_flights.search.call_args
+ assert args[0].passenger_info.adults == 2
+
+
+def test_flights_json_query_echoes_passengers(runner, mock_search_flights, mock_console):
+ """JSON query echo includes requested adult passenger count."""
+ result = runner.invoke(
+ app,
+ [
+ "flights",
+ "JFK",
+ "LAX",
+ datetime.now().strftime("%Y-%m-%d"),
+ "--passengers",
+ "3",
+ "--format",
+ "json",
+ ],
+ )
+ assert result.exit_code == 0
+ payload = json.loads(result.stdout)
+ assert payload["query"]["passengers"] == 3
+
+
def test_flights_with_airlines(runner, mock_search_flights, mock_console):
"""Repeated -a flags resolve to the matching Airline enums on the filter."""
result = runner.invoke(
diff --git a/tests/cli/test_multi.py b/tests/cli/test_multi.py
index 5742947..3eaf2cf 100644
--- a/tests/cli/test_multi.py
+++ b/tests/cli/test_multi.py
@@ -128,6 +128,27 @@ class TestMultiCityCommand:
assert args[0].trip_type == TripType.MULTI_CITY
assert len(args[0].flight_segments) == 3
+ def test_with_passengers(self, runner, mock_search_flights, mock_console):
+ """Test multi-city search passes adult passenger count into filters."""
+ date1 = _future_date(30)
+ date2 = _future_date(37)
+
+ result = runner.invoke(
+ app,
+ [
+ "multi",
+ "--leg",
+ f"SEA,HKG,{date1}",
+ "--leg",
+ f"HKG,SEA,{date2}",
+ "--passengers",
+ "2",
+ ],
+ )
+ assert result.exit_code == 0
+ args, _ = mock_search_flights.search.call_args
+ assert args[0].passenger_info.adults == 2
+
def test_with_cabin_class(self, runner, mock_search_flights, mock_console):
"""Test multi-city search with cabin class filter."""
date1 = _future_date(30)