From 9807028d465bafac938728a4d19c56034ccd52dc Mon Sep 17 00:00:00 2001 From: Wu Zhenyu Date: Wed, 14 Feb 2024 17:13:20 +0800 Subject: [PATCH] :children_crossing: Add --check --- src/mutt_language_server/__main__.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/mutt_language_server/__main__.py b/src/mutt_language_server/__main__.py index 18c8c68..54e9e99 100644 --- a/src/mutt_language_server/__main__.py +++ b/src/mutt_language_server/__main__.py @@ -43,6 +43,18 @@ def get_parser(): default=2, help="generated json's indent", ) + parser.add_argument( + "--check", + nargs="*", + default={}, + help="check file's errors and warnings", + ) + parser.add_argument( + "--color", + choices=["auto", "always", "never"], + default="auto", + help="when to display color, default: %(default)s", + ) parser.add_argument( "--output-format", choices=["json", "yaml", "toml"], @@ -56,8 +68,12 @@ def main() -> None: r"""Parse arguments and provide shell completions.""" args = get_parser().parse_args() - if args.generate_schema: + if args.generate_schema or args.check: + from tree_sitter_lsp.diagnose import check from tree_sitter_lsp.utils import pprint + from tree_sitter_muttrc import parser + + from .finders import DIAGNOSTICS_FINDER_CLASSES if args.generate_schema: from .misc import get_schema @@ -68,6 +84,15 @@ def main() -> None: indent=args.indent, ) return None + exit( + check( + args.check, + parser.parse, + DIAGNOSTICS_FINDER_CLASSES, + None, + args.color, + ) + ) from .server import MuttLanguageServer