cli: move entrypoint and add propre debug flag

This commit is contained in:
dece 2022-12-05 11:04:06 +01:00
parent f1af40af79
commit dc7c7a877e
2 changed files with 27 additions and 8 deletions

View file

@ -1,8 +0,0 @@
from italianswirls.server import LS
if __name__ == "__main__":
import logging
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
root_logger.addHandler(logging.FileHandler("/tmp/a.log"))
LS.start_io()

27
italianswirls/cli.py Normal file
View file

@ -0,0 +1,27 @@
"""CLI to start the language server"""
import argparse
import logging
from italianswirls.server import LS
DESCRIPTION = "Italian Swirls, a minimal Python language server based on Jedi."
DEFAULT_LOG_FILE = "/tmp/italianswirls.log"
def main():
argparser = argparse.ArgumentParser(description=DESCRIPTION)
argparser.add_argument("-d", "--debug", nargs="?", const=DEFAULT_LOG_FILE,
help=f"debug log (default: {DEFAULT_LOG_FILE})")
args = argparser.parse_args()
if debug_log_file := args.debug:
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
root_logger.addHandler(logging.FileHandler(debug_log_file))
LS.start_io()
if __name__ == "__main__":
main()