feat(cli): add help messages to all commands
This commit is contained in:
@@ -14,7 +14,7 @@ from midas.cli.highlighter import DiagnosticsHighlighter
|
||||
from midas.cli.utils import DiagnosticPrinter
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.command(help="Run type checker and report diagnostics")
|
||||
@click.argument("file", type=click.File("r"))
|
||||
@click.option("-t", "--types", type=click.File("r"), multiple=True)
|
||||
@click.option("-l", "--highlight", type=click.File("w"))
|
||||
|
||||
@@ -3,19 +3,20 @@
|
||||
# midas compile <file.py> [--types <file.midas>] [-o <output>] [--assertions|--strict|--no-checks]
|
||||
# ```
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import TextIO
|
||||
|
||||
import click
|
||||
|
||||
from midas.checker.checker import TypeChecker
|
||||
from midas.checker.diagnostic import Diagnostic
|
||||
from midas.checker.diagnostic import Diagnostic, DiagnosticType
|
||||
from midas.cli.utils import DiagnosticPrinter
|
||||
from midas.generator.generator import Generator
|
||||
from midas.utils import TypedAST
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.command(help="Compile source")
|
||||
@click.argument("file", type=click.File("r"))
|
||||
@click.option("-t", "--types", type=click.File("r"), multiple=True)
|
||||
def compile(
|
||||
@@ -34,5 +35,8 @@ def compile(
|
||||
printer = DiagnosticPrinter()
|
||||
printer.print_all(diagnostics)
|
||||
|
||||
if any(map(lambda d: d.type == DiagnosticType.ERROR, diagnostics)):
|
||||
sys.exit(1)
|
||||
|
||||
generator = Generator(workdir=source_path.parent)
|
||||
generator.generate(typed_ast, source_path)
|
||||
|
||||
@@ -9,7 +9,7 @@ from midas.lexer.token import Token
|
||||
from midas.parser.midas import MidasParser
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.command(help="Parse and pretty print a Midas file")
|
||||
@click.argument("file", type=click.File("r"))
|
||||
@click.option("-o", "--output", type=click.File("w"), default="-")
|
||||
def format(file: TextIO, output: TextIO):
|
||||
|
||||
@@ -46,7 +46,10 @@ def highlight_midas(source: str, path: str) -> Highlighter:
|
||||
return highlighter
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.command(
|
||||
help="Parse a Python or Midas file and produce a highlighted version showing AST node types inline",
|
||||
short_help="Parse and highlight a Python or Midas file",
|
||||
)
|
||||
@click.argument("file", type=click.File("r"))
|
||||
@click.option("-o", "--output", type=click.File("w"), default="-")
|
||||
def highlight(output: TextIO, file: TextIO):
|
||||
|
||||
@@ -45,7 +45,7 @@ def dump_midas_ast(source: str, filename: str) -> str:
|
||||
return dump
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.command(help="Parse a Python or Midas file and pretty-print its AST")
|
||||
@click.argument("file", type=click.File("r"))
|
||||
@click.option("--raw", is_flag=True)
|
||||
def parse(file: TextIO, raw: bool):
|
||||
|
||||
@@ -12,7 +12,7 @@ from midas.checker.checker import TypeChecker
|
||||
from midas.checker.types import Type
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.command(help="Dump types registry")
|
||||
@click.option("-t", "--types", type=click.File("r"), multiple=True)
|
||||
def dump_registry(
|
||||
types: tuple[TextIO],
|
||||
|
||||
@@ -14,7 +14,7 @@ from midas.cli.highlighter import DiagnosticsHighlighter
|
||||
from midas.cli.utils import DiagnosticPrinter
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.command(help="Print typing judgements")
|
||||
@click.argument("file", type=click.File("r"))
|
||||
@click.option("-t", "--types", type=click.File("r"), multiple=True)
|
||||
@click.option("-l", "--highlight", type=click.File("w"))
|
||||
|
||||
@@ -14,7 +14,7 @@ from midas.cli.highlighter import DiagnosticsHighlighter
|
||||
from midas.cli.utils import DiagnosticPrinter
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.command(help="Validate Midas definitions")
|
||||
@click.argument("file", type=click.File("r"))
|
||||
@click.option("-l", "--highlight", type=click.File("w"))
|
||||
def validate(
|
||||
|
||||
Reference in New Issue
Block a user