feat(cli): add --version option 🤖🤖🤖 (#563)
* feat(cli): add version flag * fix(cli): parse args before acquiring single-instance lock so --version works while app is running Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
81bfe9345b
commit
eb16a34328
+13
-3
@@ -8,6 +8,8 @@ import atexit
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from .version import __version__
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
@@ -21,7 +23,13 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
def parse_arguments():
|
||||
"""Parse command line arguments."""
|
||||
parser = argparse.ArgumentParser(description="Vocalinux")
|
||||
parser = argparse.ArgumentParser(prog="vocalinux", description="Vocalinux")
|
||||
parser.add_argument(
|
||||
"--version",
|
||||
action="version",
|
||||
version=f"%(prog)s {__version__}",
|
||||
help="Show the installed Vocalinux version and exit",
|
||||
)
|
||||
parser.add_argument("--debug", action="store_true", help="Enable debug logging")
|
||||
# default model, language and engine are loaded from default config
|
||||
# due to priority of args over config
|
||||
@@ -214,6 +222,10 @@ def check_appindicator_support():
|
||||
|
||||
def main():
|
||||
"""Main entry point for the application."""
|
||||
# Parse arguments first so flags like --version work even when
|
||||
# another instance already holds the single-instance lock
|
||||
args = parse_arguments()
|
||||
|
||||
# Check for single instance BEFORE any initialization
|
||||
from . import single_instance
|
||||
|
||||
@@ -241,8 +253,6 @@ def main():
|
||||
# Register cleanup to release lock on exit
|
||||
atexit.register(single_instance.release_lock)
|
||||
|
||||
args = parse_arguments()
|
||||
|
||||
# Configure debug logging if requested
|
||||
if args.debug:
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
||||
Reference in New Issue
Block a user