Show version number
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
__version__ = "0.4.0"
|
|
||||||
APP_NAME = "A1 Swap Mod Packer"
|
APP_NAME = "A1 Swap Mod Packer"
|
||||||
|
__version__ = "0.4.0"
|
||||||
|
APP_TITLE = f"{APP_NAME} v{__version__}"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import argparse
|
|||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from . import APP_NAME
|
from . import APP_NAME, APP_TITLE, __version__
|
||||||
from .core import (
|
from .core import (
|
||||||
BuildOptions,
|
BuildOptions,
|
||||||
PlateJob,
|
PlateJob,
|
||||||
@@ -70,7 +70,11 @@ def list_swap_gcode_command(args: argparse.Namespace) -> int:
|
|||||||
|
|
||||||
|
|
||||||
def create_parser() -> argparse.ArgumentParser:
|
def create_parser() -> argparse.ArgumentParser:
|
||||||
parser = argparse.ArgumentParser(prog="a1-swap-mod-packer", description="Pack repeated Bambu A1 SwapMod plates into one 3MF job.")
|
parser = argparse.ArgumentParser(
|
||||||
|
prog="a1-swap-mod-packer",
|
||||||
|
description=f"{APP_TITLE} - Pack repeated Bambu A1 SwapMod plates into one 3MF job.",
|
||||||
|
)
|
||||||
|
parser.add_argument("--version", action="version", version=f"{APP_NAME} {__version__}")
|
||||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||||
|
|
||||||
build = subparsers.add_parser("build", help="Build a packed 3MF file.")
|
build = subparsers.add_parser("build", help="Build a packed 3MF file.")
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ try:
|
|||||||
except ImportError as exc: # pragma: no cover
|
except ImportError as exc: # pragma: no cover
|
||||||
raise SystemExit("PySide6 is required to run the GUI. Install it with: pip install PySide6") from exc
|
raise SystemExit("PySide6 is required to run the GUI. Install it with: pip install PySide6") from exc
|
||||||
|
|
||||||
from . import APP_NAME
|
from . import APP_NAME, APP_TITLE
|
||||||
from .core import (
|
from .core import (
|
||||||
BuildOptions,
|
BuildOptions,
|
||||||
PlateJob,
|
PlateJob,
|
||||||
@@ -265,7 +265,7 @@ class DropTableWidget(QTableWidget):
|
|||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setWindowTitle(APP_NAME)
|
self.setWindowTitle(APP_TITLE)
|
||||||
self.resize(960, 860)
|
self.resize(960, 860)
|
||||||
self.setAcceptDrops(True)
|
self.setAcceptDrops(True)
|
||||||
self._updating_table = False
|
self._updating_table = False
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import contextlib
|
||||||
|
import io
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from a1_swap_mod_packer import APP_NAME, APP_TITLE, __version__
|
||||||
|
from a1_swap_mod_packer.cli import create_parser
|
||||||
|
|
||||||
|
|
||||||
|
class VersionDisplayTest(unittest.TestCase):
|
||||||
|
def test_app_title_uses_shared_version(self) -> None:
|
||||||
|
self.assertEqual(APP_TITLE, f"{APP_NAME} v{__version__}")
|
||||||
|
|
||||||
|
def test_cli_help_and_version_use_shared_version(self) -> None:
|
||||||
|
parser = create_parser()
|
||||||
|
self.assertIn(APP_TITLE, parser.format_help())
|
||||||
|
|
||||||
|
stdout = io.StringIO()
|
||||||
|
with self.assertRaises(SystemExit) as caught, contextlib.redirect_stdout(stdout):
|
||||||
|
parser.parse_args(["--version"])
|
||||||
|
|
||||||
|
self.assertEqual(caught.exception.code, 0)
|
||||||
|
self.assertEqual(stdout.getvalue().strip(), f"{APP_NAME} {__version__}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user