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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: interlocking
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: A lightweight task dispatcher with explicit control.
5
5
  Keywords: task-runner,batch,exclusive-lock,cli,mutex,distributed-lock
6
6
  Author: alpine
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "interlocking"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "A lightweight task dispatcher with explicit control."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "interlocking"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "A lightweight task dispatcher with explicit control."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -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