Skip to content

armgit / fli

Public Imported from GitHub
0

Google Flights MCP, CLI and Python Library

fix: accept space-separated airline codes in CLI (#112)

Trevin Chowfc1768647bbe
diff --git a/fli/cli/commands/dates.py b/fli/cli/commands/dates.py
index c49635b..3576cb4 100644
--- a/fli/cli/commands/dates.py
+++ b/fli/cli/commands/dates.py
@@ -1,5 +1,6 @@
"""Date search CLI command for finding cheapest travel dates."""
+import re
from datetime import datetime, timedelta
from typing import Annotated
@@ -86,7 +87,7 @@ def dates(
typer.Option(
"--airlines",
"-a",
- help="List of airline IATA codes (e.g., BA KL)",
+ help="Airline IATA codes (e.g., BA,KL or repeated --airlines BA --airlines KL)",
),
] = None,
is_round_trip: Annotated[
@@ -218,6 +219,14 @@ def dates(
trip_type = TripType.ROUND_TRIP if is_round_trip else TripType.ONE_WAY
stops = parse_max_stops(max_stops)
seat_type = parse_cabin_class(cabin_class)
+ # Normalize airlines: split each element on commas to support "BA,KL" in a single flag
+ if airlines:
+ airlines = [
+ code.strip().upper()
+ for item in airlines
+ for code in re.split(r"[,\s]+", item)
+ if code.strip()
+ ]
parsed_airlines = parse_airlines(airlines)
selected_days = _build_selected_days(
monday=monday,
diff --git a/fli/cli/commands/flights.py b/fli/cli/commands/flights.py
index db37d9b..9307f17 100644
--- a/fli/cli/commands/flights.py
+++ b/fli/cli/commands/flights.py
@@ -1,5 +1,6 @@
"""Flight search CLI command."""
+import re
from typing import Annotated, Any
import typer
@@ -54,6 +55,14 @@ def _search_flights_core(
currency: str = "USD",
) -> None:
"""Core flight search functionality."""
+ # Normalize airlines: split each element on commas/spaces to support "BA,KL" in a single flag
+ if airlines:
+ airlines = [
+ code.strip().upper()
+ for item in airlines
+ for code in re.split(r"[,\s]+", item)
+ if code.strip()
+ ]
query: dict[str, Any] = {
"origin": origin.upper(),
"destination": destination.upper(),
@@ -222,7 +231,7 @@ def flights(
typer.Option(
"--airlines",
"-a",
- help="List of airline IATA codes (e.g., BA KL)",
+ help="Airline IATA codes (e.g., BA,KL or repeated --airlines BA --airlines KL)",
),
] = None,
cabin_class: Annotated[