INNER CODE UNIT · Python
_DefaultQueryGroup
tomascupr/sandstorm · src/sandstorm/cli.py:42
class _DefaultQueryGroup(click.Group):
"""Click group that treats unknown first arguments as query prompts."""
def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]:
if args and args[0] not in self.commands and not args[0].startswith("-"):
args.insert(0, "query")
return super().parse_args(ctx, args)
def _print_event(line: str) -> None:
"""Parse a JSON event line and print it to the appropriate stream."""
try:
event = json.loads(line)
except json.JSONDecodeError:
click.echo(line, nl=False)
return
event_type = event.get("type")