Added python and macOS versions to --version (#1008)
This commit is contained in:
@@ -14,7 +14,7 @@ from .about import about
|
|||||||
from .add_locations import add_locations
|
from .add_locations import add_locations
|
||||||
from .albums import albums
|
from .albums import albums
|
||||||
from .batch_edit import batch_edit
|
from .batch_edit import batch_edit
|
||||||
from .cli_params import DB_OPTION, DEBUG_OPTIONS, JSON_OPTION
|
from .cli_params import DB_OPTION, DEBUG_OPTIONS, JSON_OPTION, VERSION_OPTION
|
||||||
from .common import OSXPHOTOS_HIDDEN
|
from .common import OSXPHOTOS_HIDDEN
|
||||||
from .debug_dump import debug_dump
|
from .debug_dump import debug_dump
|
||||||
from .docs import docs_command
|
from .docs import docs_command
|
||||||
@@ -58,7 +58,7 @@ CTX_SETTINGS = dict(help_option_names=["-h", "--help"])
|
|||||||
|
|
||||||
|
|
||||||
@click.group(context_settings=CTX_SETTINGS)
|
@click.group(context_settings=CTX_SETTINGS)
|
||||||
@click.version_option(__version__, "--version", "-v")
|
@VERSION_OPTION
|
||||||
@DB_OPTION
|
@DB_OPTION
|
||||||
@JSON_OPTION
|
@JSON_OPTION
|
||||||
@DEBUG_OPTIONS
|
@DEBUG_OPTIONS
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from typing import Any, Callable
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from .common import OSXPHOTOS_HIDDEN
|
from .common import OSXPHOTOS_HIDDEN, print_version
|
||||||
from .param_types import *
|
from .param_types import *
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
@@ -19,8 +19,9 @@ __all__ = [
|
|||||||
"JSON_OPTION",
|
"JSON_OPTION",
|
||||||
"QUERY_OPTIONS",
|
"QUERY_OPTIONS",
|
||||||
"THEME_OPTION",
|
"THEME_OPTION",
|
||||||
"VERBOSE_OPTION",
|
|
||||||
"TIMESTAMP_OPTION",
|
"TIMESTAMP_OPTION",
|
||||||
|
"VERBOSE_OPTION",
|
||||||
|
"VERSION_OPTION",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -676,3 +677,12 @@ _TIMESTAMP_PARAMETER = click.Option(
|
|||||||
["--timestamp"], is_flag=True, help="Add time stamp to verbose output"
|
["--timestamp"], is_flag=True, help="Add time stamp to verbose output"
|
||||||
)
|
)
|
||||||
TIMESTAMP_OPTION = make_click_option_decorator(_TIMESTAMP_PARAMETER)
|
TIMESTAMP_OPTION = make_click_option_decorator(_TIMESTAMP_PARAMETER)
|
||||||
|
|
||||||
|
_VERSION_PARAMETER = click.Option(
|
||||||
|
["--version", "-v", "_version_flag"],
|
||||||
|
is_flag=True,
|
||||||
|
help="Show the version and exit.",
|
||||||
|
callback=print_version,
|
||||||
|
)
|
||||||
|
|
||||||
|
VERSION_OPTION = make_click_option_decorator(_VERSION_PARAMETER)
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@@ -13,7 +15,7 @@ from xdg import xdg_config_home, xdg_data_home
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
from osxphotos._constants import APP_NAME
|
from osxphotos._constants import APP_NAME
|
||||||
from osxphotos._version import __version__
|
from osxphotos._version import __version__
|
||||||
from osxphotos.utils import get_latest_version
|
from osxphotos.utils import get_latest_version, get_macos_version
|
||||||
|
|
||||||
# used to show/hide hidden commands
|
# used to show/hide hidden commands
|
||||||
OSXPHOTOS_HIDDEN = not bool(os.getenv("OSXPHOTOS_SHOW_HIDDEN", default=False))
|
OSXPHOTOS_HIDDEN = not bool(os.getenv("OSXPHOTOS_SHOW_HIDDEN", default=False))
|
||||||
@@ -106,3 +108,13 @@ def check_version():
|
|||||||
"to suppress this message and prevent osxphotos from checking for latest version.",
|
"to suppress this message and prevent osxphotos from checking for latest version.",
|
||||||
err=True,
|
err=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def print_version(ctx, param, value):
|
||||||
|
"""Print version, this is a callback for the --version option"""
|
||||||
|
if not value:
|
||||||
|
return
|
||||||
|
click.echo(f"osxphotos, version {__version__}")
|
||||||
|
click.echo(f"Python {sys.version}")
|
||||||
|
click.echo(f"macOS {'.'.join(get_macos_version())}, {platform.machine()}")
|
||||||
|
ctx.exit()
|
||||||
|
|||||||
@@ -31,10 +31,11 @@ __all__ = [
|
|||||||
"dd_to_dms_str",
|
"dd_to_dms_str",
|
||||||
"expand_and_validate_filepath",
|
"expand_and_validate_filepath",
|
||||||
"get_last_library_path",
|
"get_last_library_path",
|
||||||
|
"get_macos_version",
|
||||||
"get_system_library_path",
|
"get_system_library_path",
|
||||||
"hexdigest",
|
"hexdigest",
|
||||||
"increment_filename",
|
|
||||||
"increment_filename_with_count",
|
"increment_filename_with_count",
|
||||||
|
"increment_filename",
|
||||||
"lineno",
|
"lineno",
|
||||||
"list_directory",
|
"list_directory",
|
||||||
"list_photo_libraries",
|
"list_photo_libraries",
|
||||||
|
|||||||
Reference in New Issue
Block a user