oaknut-cli 13.4.0__tar.gz → 13.6.0__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: oaknut-cli
3
- Version: 13.4.0
3
+ Version: 13.6.0
4
4
  Summary: Shared CLI toolkit for the oaknut family: the contributed-command axis and report-rendering helpers a disc command needs, below the filesystem packages.
5
5
  Author-email: Robert Smallshire <robert@smallshire.org.uk>
6
6
  License-Expression: MIT
@@ -12,11 +12,10 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
17
16
  Classifier: Programming Language :: Python :: 3.13
18
17
  Classifier: Topic :: System :: Filesystems
19
- Requires-Python: >=3.11
18
+ Requires-Python: >=3.12
20
19
  Description-Content-Type: text/markdown
21
20
  License-File: LICENSE
22
21
  Requires-Dist: oaknut-exception>=10.0
@@ -10,14 +10,13 @@ description = "Shared CLI toolkit for the oaknut family: the contributed-command
10
10
  readme = "README.md"
11
11
  license = "MIT"
12
12
  license-files = ["LICENSE"]
13
- requires-python = ">=3.11"
13
+ requires-python = ">=3.12"
14
14
  classifiers = [
15
15
  "Development Status :: 3 - Alpha",
16
16
  "Intended Audience :: Developers",
17
17
  "Operating System :: OS Independent",
18
18
  "Programming Language :: Python :: 3",
19
19
  "Programming Language :: Python :: 3 :: Only",
20
- "Programming Language :: Python :: 3.11",
21
20
  "Programming Language :: Python :: 3.12",
22
21
  "Programming Language :: Python :: 3.13",
23
22
  "Topic :: System :: Filesystems",
@@ -11,7 +11,9 @@ It provides:
11
11
  registered by filesystem packages on the ``oaknut.command`` entry-point
12
12
  namespace (see :func:`contributed_commands`); and
13
13
  - report-rendering helpers shared between the generic ``disc`` commands
14
- and the contributed ones.
14
+ and the contributed ones; and
15
+ - the ``--meta-format`` choice type the host-boundary commands of
16
+ ``disc`` and ``zip`` share (see :class:`MetaFormatChoice`).
15
17
 
16
18
  See ``docs/dev/contributed-commands.md`` for the design.
17
19
  """
@@ -28,6 +30,7 @@ from oaknut.cli.help import (
28
30
  strip_rst,
29
31
  use_plain_help,
30
32
  )
33
+ from oaknut.cli.meta_format import META_FORMAT_NONE, MetaFormatChoice
31
34
  from oaknut.cli.reports import (
32
35
  SECTOR_SIZE,
33
36
  address_cell,
@@ -40,7 +43,7 @@ from oaknut.cli.reports import (
40
43
  text_cell,
41
44
  )
42
45
 
43
- __version__ = "13.4.0"
46
+ __version__ = "13.6.0"
44
47
 
45
48
  __all__ = [
46
49
  "COMMAND_KIND",
@@ -49,6 +52,8 @@ __all__ = [
49
52
  "PlainHelpFormatter",
50
53
  "strip_rst",
51
54
  "use_plain_help",
55
+ "META_FORMAT_NONE",
56
+ "MetaFormatChoice",
52
57
  "SECTOR_SIZE",
53
58
  "address_cell",
54
59
  "bytes_cell",
@@ -0,0 +1,34 @@
1
+ """The ``--meta-format`` choice shared by every host-boundary command."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import click
6
+ from oaknut.file import DEPRECATED_META_FORMATS, MetaFormat
7
+
8
+ #: The choice meaning "carry no metadata", alongside the MetaFormat values.
9
+ META_FORMAT_NONE = "none"
10
+
11
+
12
+ class MetaFormatChoice(click.Choice):
13
+ """A case-insensitive choice of :class:`~oaknut.file.MetaFormat` values or ``none``.
14
+
15
+ The choices follow :class:`~oaknut.file.MetaFormat`, so a new format
16
+ reaches every command at once. A deprecated name from
17
+ :data:`~oaknut.file.DEPRECATED_META_FORMATS` is accepted, with a
18
+ warning on stderr, and converts to the name that replaces it; it is
19
+ not listed in help.
20
+ """
21
+
22
+ def __init__(self) -> None:
23
+ super().__init__([*(f.value for f in MetaFormat), META_FORMAT_NONE], case_sensitive=False)
24
+
25
+ def convert(self, value, param, ctx):
26
+ if isinstance(value, str):
27
+ replacement = DEPRECATED_META_FORMATS.get(value.lower())
28
+ if replacement is not None:
29
+ click.echo(
30
+ f"warning: --meta-format {value} is deprecated; use {replacement.value}.",
31
+ err=True,
32
+ )
33
+ value = replacement.value
34
+ return super().convert(value, param, ctx)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oaknut-cli
3
- Version: 13.4.0
3
+ Version: 13.6.0
4
4
  Summary: Shared CLI toolkit for the oaknut family: the contributed-command axis and report-rendering helpers a disc command needs, below the filesystem packages.
5
5
  Author-email: Robert Smallshire <robert@smallshire.org.uk>
6
6
  License-Expression: MIT
@@ -12,11 +12,10 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.11
16
15
  Classifier: Programming Language :: Python :: 3.12
17
16
  Classifier: Programming Language :: Python :: 3.13
18
17
  Classifier: Topic :: System :: Filesystems
19
- Requires-Python: >=3.11
18
+ Requires-Python: >=3.12
20
19
  Description-Content-Type: text/markdown
21
20
  License-File: LICENSE
22
21
  Requires-Dist: oaknut-exception>=10.0
@@ -4,6 +4,7 @@ pyproject.toml
4
4
  src/oaknut/cli/__init__.py
5
5
  src/oaknut/cli/commands.py
6
6
  src/oaknut/cli/help.py
7
+ src/oaknut/cli/meta_format.py
7
8
  src/oaknut/cli/reports.py
8
9
  src/oaknut_cli.egg-info/PKG-INFO
9
10
  src/oaknut_cli.egg-info/SOURCES.txt
@@ -12,4 +13,5 @@ src/oaknut_cli.egg-info/requires.txt
12
13
  src/oaknut_cli.egg-info/top_level.txt
13
14
  tests/test_commands.py
14
15
  tests/test_help.py
16
+ tests/test_meta_format.py
15
17
  tests/test_reports.py
@@ -0,0 +1,49 @@
1
+ """Tests for the --meta-format choice type."""
2
+
3
+ import click
4
+ from click.testing import CliRunner
5
+ from oaknut.cli import MetaFormatChoice
6
+ from oaknut.file import MetaFormat
7
+
8
+
9
+ def _cli():
10
+ @click.command()
11
+ @click.option("--meta-format", type=MetaFormatChoice(), default="inf-trad")
12
+ def show(meta_format):
13
+ click.echo(meta_format)
14
+
15
+ return show
16
+
17
+
18
+ class TestMetaFormatChoice:
19
+ def test_choices_are_every_format_and_none(self):
20
+ assert list(MetaFormatChoice().choices) == [*(f.value for f in MetaFormat), "none"]
21
+
22
+ def test_deprecated_names_are_not_listed(self):
23
+ assert "filename-mos" not in MetaFormatChoice().choices
24
+
25
+ def test_accepts_a_current_name(self):
26
+ result = CliRunner().invoke(_cli(), ["--meta-format", "filename-loadexec"])
27
+ assert result.exit_code == 0
28
+ assert result.stdout == "filename-loadexec\n"
29
+
30
+ def test_accepts_none(self):
31
+ result = CliRunner().invoke(_cli(), ["--meta-format", "none"])
32
+ assert result.exit_code == 0
33
+ assert result.stdout == "none\n"
34
+
35
+ def test_is_case_insensitive(self):
36
+ result = CliRunner().invoke(_cli(), ["--meta-format", "INF-PIEB"])
37
+ assert result.exit_code == 0
38
+ assert result.stdout == "inf-pieb\n"
39
+
40
+ def test_deprecated_name_resolves_and_warns(self):
41
+ result = CliRunner().invoke(_cli(), ["--meta-format", "filename-mos"])
42
+ assert result.exit_code == 0
43
+ assert result.stdout == "filename-loadexec\n"
44
+ assert "deprecated" in result.stderr
45
+ assert "filename-loadexec" in result.stderr
46
+
47
+ def test_rejects_an_unknown_name(self):
48
+ result = CliRunner().invoke(_cli(), ["--meta-format", "filename-nfs"])
49
+ assert result.exit_code == 2
File without changes
File without changes
File without changes