interlocking 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {interlocking-0.2.0 → interlocking-0.2.1}/PKG-INFO +1 -1
- {interlocking-0.2.0 → interlocking-0.2.1}/pyproject.toml +1 -1
- {interlocking-0.2.0 → interlocking-0.2.1}/pyproject.toml.orig +1 -1
- {interlocking-0.2.0 → interlocking-0.2.1}/src/interlocking/cli.py +7 -0
- {interlocking-0.2.0 → interlocking-0.2.1}/LICENSE +0 -0
- {interlocking-0.2.0 → interlocking-0.2.1}/README.md +0 -0
- {interlocking-0.2.0 → interlocking-0.2.1}/src/interlocking/__init__.py +0 -0
- {interlocking-0.2.0 → interlocking-0.2.1}/src/interlocking/dispatcher.py +0 -0
- {interlocking-0.2.0 → interlocking-0.2.1}/src/interlocking/lambda_.py +0 -0
- {interlocking-0.2.0 → interlocking-0.2.1}/src/interlocking/line.py +0 -0
- {interlocking-0.2.0 → interlocking-0.2.1}/src/interlocking/models.py +0 -0
- {interlocking-0.2.0 → interlocking-0.2.1}/src/interlocking/station.py +0 -0
|
@@ -283,6 +283,7 @@ class InterlockingCLI:
|
|
|
283
283
|
dispatcher: 構築済みの TrainDispatcher。
|
|
284
284
|
prog: CLI プログラム名(argparse の prog)。
|
|
285
285
|
description: CLI の説明文。
|
|
286
|
+
version: アプリの版。渡したときだけ ``--version`` が付き、``<prog> <version>`` を出す(ADR-0009)。
|
|
286
287
|
"""
|
|
287
288
|
|
|
288
289
|
def __init__(
|
|
@@ -290,10 +291,12 @@ class InterlockingCLI:
|
|
|
290
291
|
dispatcher: TrainDispatcher,
|
|
291
292
|
prog: str = "interlocking",
|
|
292
293
|
description: str = "",
|
|
294
|
+
version: Optional[str] = None,
|
|
293
295
|
) -> None:
|
|
294
296
|
self.dispatcher = dispatcher
|
|
295
297
|
self.prog = prog
|
|
296
298
|
self.description = description
|
|
299
|
+
self.version = version
|
|
297
300
|
|
|
298
301
|
def parse_args(self, argv: Optional[list] = None) -> CliRequest:
|
|
299
302
|
"""パーサーを構築して引数を解析する。
|
|
@@ -312,6 +315,10 @@ class InterlockingCLI:
|
|
|
312
315
|
lines = list(self.dispatcher.lines)
|
|
313
316
|
|
|
314
317
|
root = argparse.ArgumentParser(prog=self.prog, description=self.description)
|
|
318
|
+
if self.version is not None:
|
|
319
|
+
# argparse は version を % 書式で展開するので、利用者の文字列の % はエスケープする
|
|
320
|
+
escaped = self.version.replace("%", "%%")
|
|
321
|
+
root.add_argument("--version", action="version", version=f"%(prog)s {escaped}")
|
|
315
322
|
commands = root.add_subparsers(dest=_COMMAND, required=True, metavar="{start,abort}")
|
|
316
323
|
|
|
317
324
|
# Phase 1: 路線名だけでパーサーを構成(import なし)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|