libs.domain.command module

libs/domain/command.py

libs.domain.command.CommandAction

コマンド処理関数の型(入力文字列を受け取り、結果辞書を返す)

alias of Callable[[str | tuple[str, …]], Mapping[str, str | int | bool | tuple[str, …]]]

class libs.domain.command.CommandParser

Bases: object

引数解析クラス

__init__()
Return type:

None

analysis_argument(argument)

コマンドライン引数を解析する

Parameters:

argument (list[str]) – 引数

Returns:

結果

Return type:

ParsedCommand

day_format

日付文字列判定用正規表現

  • yyyymmdd

  • yyyy/mm/dd, yyyy/m/d

  • yyyy-mm-dd, yyyy-m-d

  • yyyy.mm.dd, yyyy.m.d

classmethod is_valid_command(word)

引数がコマンド名と一致するか判定する

Parameters:

word (str) – チェック文字列

Returns:

真偽

Return type:

bool

libs.domain.command.CommandResult

コマンド処理結果の型(パラメータ名とその値のマッピング)

alias of Mapping[str, str | int | bool | tuple[str, …]]

class libs.domain.command.CommandSpec

Bases: TypedDict

コマンドマッピングテーブル

action: Callable[[str | tuple[str, ...]], Mapping[str, str | int | bool | tuple[str, ...]]]
match: list[str]
type: Literal['int', 'str', 'sql', 'filename']
class libs.domain.command.ParsedCommand

Bases: object

コマンド解析結果

__init__(flags, arguments, unknown, search_range)
Parameters:
  • flags (dict[str, Any])

  • arguments (list[str])

  • unknown (list[str])

  • search_range (list[ExtendedDatetime])

Return type:

None

arguments: list[str]

単独オプションを格納

flags: dict[str, Any]

真偽値、引数を持つオプションを格納

search_range: list[ExtendedDatetime]

検索範囲の日時を格納

unknown: list[str]

オプションと認識されない文字列を格納(プレイヤー名候補)