-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e5d686
commit 23cde9f
Showing
17 changed files
with
134 additions
and
135 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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Defines the top-level KOL CLI.""" | ||
|
||
import click | ||
|
||
from kscale.utils.cli import recursive_help | ||
from kscale.web.pybullet import cli as pybullet_cli | ||
from kscale.web.urdf import cli as urdf_cli | ||
|
||
|
||
@click.group() | ||
def cli() -> None: | ||
"""Command line interface for interacting with the K-Scale store.""" | ||
pass | ||
|
||
|
||
cli.add_command(urdf_cli, "urdf") | ||
cli.add_command(pybullet_cli, "pybullet") | ||
|
||
if __name__ == "__main__": | ||
# python -m kscale.cli | ||
print(recursive_help(cli)) |
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 |
---|---|---|
|
@@ -8,3 +8,6 @@ email_validator | |
httpx | ||
requests | ||
pydantic | ||
|
||
# CLI | ||
click |
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Defines utilities for working with asyncio.""" | ||
|
||
import asyncio | ||
import textwrap | ||
from functools import wraps | ||
from typing import Any, Callable, Coroutine, ParamSpec, TypeVar | ||
|
||
import click | ||
|
||
T = TypeVar("T") | ||
P = ParamSpec("P") | ||
|
||
|
||
def coro(f: Callable[P, Coroutine[Any, Any, T]]) -> Callable[P, T]: | ||
@wraps(f) | ||
def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: | ||
return asyncio.run(f(*args, **kwargs)) | ||
|
||
return wrapper | ||
|
||
|
||
def recursive_help(cmd: click.Command, parent: click.Context | None = None, indent: int = 0) -> str: | ||
ctx = click.core.Context(cmd, info_name=cmd.name, parent=parent) | ||
help_text = cmd.get_help(ctx) | ||
commands = getattr(cmd, "commands", {}) | ||
for sub in commands.values(): | ||
help_text += recursive_help(sub, ctx, indent + 2) | ||
return textwrap.indent(help_text, " " * indent) |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.