gamesheet_sdk.common.cli.game_options module¶
The unified game option set shared by gamesheet-admin games and gamesheet-teams schedule games.
The two command trees drive different backends — a JSON:API season schedule for admin, the teams gateway’s
/api/schedule-game for teams — but expose one option vocabulary, so a command line written for either CLI
runs unchanged on the other.
The two backends disagree on how a game’s two teams are named. admin names them absolutely, as
--home-team-id / --visitor-team-id and their divisions. teams names them relative to “my” team,
as --team-id / --opposing-team-id plus a side flag — --home / --visitor, spelled --away
on update — saying which side that team is on.
Both spellings are accepted by both CLIs. resolve_game_sides() translates whichever was given into
GameSides, which carries the absolute pair plus the home_flag each backend needs. These are
therefore equivalent everywhere:
--home-team-id 10 --visitor-team-id 20
--team-id 10 --opposing-team-id 20 --home
--team-id 20 --opposing-team-id 10 --visitor
Naming the same side twice with different values is a usage error.
- class gamesheet_sdk.common.cli.game_options.GameArgs[source]¶
Bases:
objectA typed view over the unified game option set.
The game commands take
**paramsrather than three dozen named parameters, and turn it into one of these. Every field is optional at this level;createenforces its own requirements viaGameSides.require()and click’srequired=.- times¶
The raw start/end/duration inputs.
- Type:
- times: GameTimeArgs¶
- __init__(sides, times, season_id, game_id, number, game_type, location, scorekeeper_name, scorekeeper_phone, broadcaster, time_zone_name, time_zone_offset, home_label, visitor_label, output_format, output_path, columns_spec)¶
- class gamesheet_sdk.common.cli.game_options.GameSides[source]¶
Bases:
objectA game’s two teams, held absolutely, plus which side is the acting team.
- property team_id: str | None¶
The acting team’s identifier.
- Returns:
str | None –
home_team_idwhen the acting team is home, elsevisitor_team_id.
- property division_id: str | None¶
The acting team’s division identifier.
- Returns:
str | None –
home_division_idwhen the acting team is home, elsevisitor_division_id.
- property opposing_team_id: str | None¶
The opposing team’s identifier.
- Returns:
str | None –
visitor_team_idwhen the acting team is home, elsehome_team_id.
- property opposing_division_id: str | None¶
The opposing team’s division identifier.
- Returns:
str | None –
visitor_division_idwhen the acting team is home, elsehome_division_id.
- require()[source]¶
Narrow to a
RequiredGameSides, rejecting any side left unspecified.- Returns:
RequiredGameSides – The same sides with every identifier known to be present.
- Return type:
- __init__(home_team_id, home_division_id, visitor_team_id, visitor_division_id, home_flag)¶
- class gamesheet_sdk.common.cli.game_options.GameTimeArgs[source]¶
Bases:
objectThe seven start/end/duration inputs, straight off the command line.
- __init__(start_datetime, start_date, start_time, end_datetime, end_date, end_time, duration)¶
- class gamesheet_sdk.common.cli.game_options.RequiredGameSides[source]¶
Bases:
objectA fully specified pair of sides, as
createneeds.- property team_id: str¶
The acting team’s identifier.
- Returns:
str –
home_team_idwhen the acting team is home, elsevisitor_team_id.
- property division_id: str¶
The acting team’s division identifier.
- Returns:
str –
home_division_idwhen the acting team is home, elsevisitor_division_id.
- property opposing_team_id: str¶
The opposing team’s identifier.
- Returns:
str –
visitor_team_idwhen the acting team is home, elsehome_team_id.
- property opposing_division_id: str¶
The opposing team’s division identifier.
- Returns:
str –
visitor_division_idwhen the acting team is home, elsehome_division_id.
- __init__(home_team_id, home_division_id, visitor_team_id, visitor_division_id, home_flag)¶
- gamesheet_sdk.common.cli.game_options.explicit_side_flag(params)[source]¶
Return the side the user actually named, or
Noneif they named none.updatesendshome_flagto the teams gateway only when it was explicitly given, so an update that does not mention a side leaves the game’s existing side alone.
- gamesheet_sdk.common.cli.game_options.game_detail_options(*, required)[source]¶
Build the decorator adding the non-time, non-side game options.
- gamesheet_sdk.common.cli.game_options.game_id_option(func)[source]¶
Add the
--game-idoption under all three accepted spellings.- Parameters:
func (F) – The command function to decorate.
- Returns:
F – The decorated command function.
- Return type:
F
- gamesheet_sdk.common.cli.game_options.game_side_options(func)[source]¶
Add both spellings of the home/visitor team and division options.
Requiredness is enforced by
resolve_game_sides(), not by click, because each side has two accepted spellings and click can only require one option at a time.- Parameters:
func (F) – The command function to decorate.
- Returns:
F – The decorated command function.
- Return type:
F
- gamesheet_sdk.common.cli.game_options.game_time_options(func)[source]¶
Add the seven start/end/duration options both CLIs accept.
- Parameters:
func (F) – The command function to decorate.
- Returns:
F – The decorated command function.
- Return type:
F
- gamesheet_sdk.common.cli.game_options.parse_game_args(params)[source]¶
Turn a game command’s collected click parameters into a
GameArgs.
- gamesheet_sdk.common.cli.game_options.requiredness(*, required)[source]¶
Build the
required/defaultkeyword pair for an option.Gotcha worth preserving: click 8.4.2 silently ignores
required=Truewhendefault=Noneis also passed explicitly — the option simply arrives asNoneand the body runs. Passing nodefaultat all is not the same thing as passingdefault=None, even though click’s implicit default isNone. So a required option must omit the key entirely.- Parameters:
required (bool) – Whether the option is mandatory.
- Returns:
dict[str, Any] – Keyword arguments to splat into
click.option().- Return type:
- gamesheet_sdk.common.cli.game_options.resolve_game_sides(*, home_team_id, home_division_id, visitor_team_id, visitor_division_id, team_id, division_id, opposing_team_id, opposing_division_id, home_flag, away_flag=False, default_home=True)[source]¶
Translate whichever team-naming spelling was used into a single
GameSides.- Parameters:
home_team_id (str | None) –
--home-team-id.home_division_id (str | None) –
--home-division-id.visitor_team_id (str | None) –
--visitor-team-id.visitor_division_id (str | None) –
--visitor-division-id.team_id (str | None) –
--team-id, the acting team.division_id (str | None) –
--division-id, the acting team’s division.opposing_team_id (str | None) –
--opposing-team-id.opposing_division_id (str | None) –
--opposing-division-id/--opposing-division.home_flag (bool | None) –
--home/--visitor.away_flag (bool) –
--away, an alias for--visitor.default_home (bool) – Which side to assume when no side flag was given.
- Returns:
GameSides – The resolved sides.
- Return type:
- gamesheet_sdk.common.cli.game_options.resolve_side_flag(*, home_flag, away_flag, default=True)[source]¶
Collapse
--home/--visitorand the--awayalias into one boolean.- Parameters:
- Returns:
bool – Whether the acting team is the home team.
- Raises:
UsageError – If
--homeand--awayare both given.- Return type:
- gamesheet_sdk.common.cli.game_options.season_id_option(*, required)[source]¶
Build the
--season-iddecorator.
- gamesheet_sdk.common.cli.game_options.sides_from_params(params, *, default_home=True)[source]¶
Collect and resolve the side options out of the raw click params.
- gamesheet_sdk.common.cli.game_options.warn_unsupported_options(cli_name, ignored)[source]¶
Warn on stderr for options this backend cannot send, then carry on.
The unified option set is deliberately wider than either backend’s payload so that a command line stays portable. Anything the receiving backend has no field for is dropped with a warning rather than an error, and the exit status is unaffected.