Skip to content

Commit

Permalink
refactor(cli): move version display to CLI
Browse files Browse the repository at this point in the history
No explicit option needed in main to display version
  • Loading branch information
gnikit committed Nov 11, 2022
1 parent 15447dc commit 8dedddc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 0 additions & 5 deletions fortls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@ def error_exit(error_str: str):


def main():
#
freeze_support()
args = cli(__name__).parse_args()

if args.version:
print(__version__)
sys.exit(0)

debug_server = (
args.debug_diagnostics
or args.debug_symbols
Expand Down
7 changes: 6 additions & 1 deletion fortls/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import json
import sys

from fortls.version import __version__


class SetAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
Expand Down Expand Up @@ -37,7 +39,8 @@ def cli(name: str = "fortls") -> argparse.ArgumentParser:
parser.add_argument(
"-v",
"--version",
action="store_true",
action="version",
version=__version__,
help="Print server version number and exit",
)
parser.add_argument(
Expand Down Expand Up @@ -225,6 +228,7 @@ def cli(name: str = "fortls") -> argparse.ArgumentParser:
group.add_argument(
"--pp_suffixes",
type=str,
default=set(),
nargs="*",
metavar="SUFFIXES",
help=(
Expand All @@ -246,6 +250,7 @@ def cli(name: str = "fortls") -> argparse.ArgumentParser:
"--pp_defs",
type=json.loads,
default={},
metavar="JSON",
help=(
"A dictionary with additional preprocessor definitions. "
"Preprocessor definitions are normally included via INCLUDE_DIRS"
Expand Down

0 comments on commit 8dedddc

Please sign in to comment.