Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --version option #252

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions mreg_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from prompt_toolkit.shortcuts import CompleteStyle, PromptSession

import mreg_cli.utilities.api as api
from mreg_cli.__about__ import __version__
from mreg_cli.cli import cli, source
from mreg_cli.config import MregCliConfig
from mreg_cli.exceptions import LoginFailedError
Expand Down Expand Up @@ -48,6 +49,12 @@ def main():
except ValueError:
pass

parser.add_argument(
"--version",
help="Show version and exit.",
action="store_true",
)

connect_args = parser.add_argument_group("connection settings")
connect_args.add_argument(
"--url",
Expand Down Expand Up @@ -134,6 +141,11 @@ def main():
)

args = parser.parse_args()

if args.version:
print(f"mreg-cli version {__version__}")
raise SystemExit() from None

setup_logging(args.verbosity)
logger.debug(f"args: {args}")
conf = {k: v for k, v in vars(args).items() if v}
Expand Down
Loading