-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from pappasam/migrate-to-argparse
Migrate to argparse
- Loading branch information
Showing
5 changed files
with
94 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,51 @@ | ||
"""Jedi Language Server command line interface.""" | ||
|
||
import click | ||
|
||
import argparse | ||
import sys | ||
|
||
from .server import SERVER | ||
|
||
|
||
@click.command() | ||
@click.version_option() | ||
def cli() -> None: | ||
"""Jedi language server. | ||
def get_version() -> str: | ||
"""Get the program version.""" | ||
# pylint: disable=import-outside-toplevel | ||
try: | ||
# Type checker for Python < 3.8 fails. | ||
# Since this ony happens here, we just ignore. | ||
from importlib.metadata import version # type: ignore | ||
except ImportError: | ||
try: | ||
# Below ignored both because this a redefinition from above, and | ||
# because importlib_metadata isn't known by mypy. Ignored because | ||
# this is intentional. | ||
from importlib_metadata import version # type: ignore | ||
except ImportError: | ||
print( | ||
"Error: unable to get version. " | ||
"If using Python < 3.8, you must install " | ||
"`importlib_metadata` to get the version.", | ||
file=sys.stderr, | ||
) | ||
sys.exit(1) | ||
return version("jedi-language-server") | ||
|
||
Examples: | ||
|
||
Run from stdio : jedi-language-server | ||
""" | ||
SERVER.start_io() # type: ignore | ||
def cli() -> None: | ||
"""Jedi language server cli entrypoint.""" | ||
parser = argparse.ArgumentParser( | ||
prog="jedi-language-server", | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
description="Jedi language server: an LSP wrapper for jedi.", | ||
epilog="""\ | ||
Examples: | ||
Run from stdio: jedi-language-server | ||
""", | ||
) | ||
parser.add_argument("--version", action="store_true") | ||
args = parser.parse_args() | ||
if args.version: | ||
print(get_version()) | ||
sys.exit(0) | ||
SERVER.start_io() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ line_length = 79 | |
|
||
[tool.poetry] | ||
name = "jedi-language-server" | ||
version = "0.28.7" | ||
version = "0.28.8" | ||
description = "A language server for Jedi!" | ||
authors = ["Sam Roeca <[email protected]>"] | ||
readme = "README.md" | ||
|
@@ -41,9 +41,8 @@ license = "MIT" | |
|
||
[tool.poetry.dependencies] | ||
python = "^3.6.1" | ||
click = ">=7.0" | ||
jedi = "0.18.0" | ||
pygls = "^0.10.0" | ||
pygls = "^0.10.2" | ||
pydantic = "^1.7" | ||
docstring-to-markdown = "0.*" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters