Skip to content

Commit

Permalink
Merge 6d99796 into f7b57a5
Browse files Browse the repository at this point in the history
  • Loading branch information
nickderobertis committed Apr 6, 2022
2 parents f7b57a5 + 6d99796 commit aec10ee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
19 changes: 19 additions & 0 deletions flexlate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
from flexlate.constants import DEFAULT_MERGED_BRANCH_NAME, DEFAULT_TEMPLATE_BRANCH_NAME
from flexlate.error_handler import simple_output_for_exceptions
from flexlate.exc import MergeConflictsAndAbortException
from flexlate.get_version import get_flexlate_version
from flexlate.logger import log
from flexlate.main import Flexlate
from flexlate.styles import print_styled, INFO_STYLE

cli = typer.Typer()

Expand Down Expand Up @@ -88,6 +90,23 @@
)


@cli.callback(invoke_without_command=True)
def pre_execute(
version: bool = typer.Option(
False,
"--version",
"-v",
show_default=False,
help="Show Flexlate version and exit",
)
):
# Support printing version and then existing with fxt --version
if version:
version_number = get_flexlate_version()
print_styled(version_number, INFO_STYLE)
exit(0)


@add_cli.command(name="source")
@simple_output_for_exceptions(
exc.GitRepoDirtyException, exc.TemplateSourceWithNameAlreadyExistsException
Expand Down
6 changes: 6 additions & 0 deletions flexlate/get_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# TODO: get version statically inside package by restructuring template
import pkg_resources


def get_flexlate_version() -> str:
return pkg_resources.get_distribution("flexlate").version
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
[mypy]
ignore_missing_imports = True

[mypy-pkg_resources.*]
ignore_missing_imports = True

# Per-module options:

0 comments on commit aec10ee

Please sign in to comment.