|
8 | 8 | from .commands.replay import replay as replay_cmd |
9 | 9 |
|
10 | 10 |
|
11 | | -@click.group(context_settings={"help_option_names": ["-h", "--help"]}) |
| 11 | +def _help_callback(ctx: click.Context, _param: click.Parameter, value: bool) -> None: |
| 12 | + if not value or ctx.resilient_parsing: |
| 13 | + return |
| 14 | + help_text = """ |
| 15 | + Stacksync CLI |
| 16 | +
|
| 17 | + Usage: |
| 18 | + $ stacksync <command> [options] |
| 19 | +
|
| 20 | + Commands: |
| 21 | + $ stacksync login # Walks the user through adding API credentials to `.stacksync/env.json` |
| 22 | + $ stacksync create # Creates a new Stacksync app in the current directory. Generated app includes a reference implementation and a README.md with coding guidelines. |
| 23 | + $ stacksync dev # Runs the app locally and enables traffic forwarding from Stacksync Workflows to localhost. Should be run in the repo created by `stacksync create`. |
| 24 | + $ stacksync replay # Replays events from the `.logs` folder of the repo to enable iterative debugging and development. |
| 25 | +
|
| 26 | + Development Workflow: |
| 27 | + Once installed, the Stacksync CLI can be used to create and manage Stacksync Apps. |
| 28 | + To create an app, the following process is recommended: |
| 29 | + - Check if logged in: `stacksync login --check`. |
| 30 | + This will return a status message prefixed with either "Logged in" or "Not logged in". |
| 31 | + - If not logged in: `stacksync login` |
| 32 | + - Create an app: `stacksync create <app-name>` |
| 33 | + This will create a new directory with the specified app-name and populate it with a reference implementation and a README.md with coding guidelines. |
| 34 | + - Run the app locally before making changes to verify functionality: `stacksync dev` |
| 35 | + - Once the reference implementation is verified to be working, modify the app as needed, adhering to the coding guidelines in the README.md. |
| 36 | +
|
| 37 | + Debugging: |
| 38 | + - Event payloads are available for inspection in the `.logs` folder of the repo created by `stacksync create`. |
| 39 | + - Events can be replayed by index or ID using the `stacksync replay` command. |
| 40 | + """ |
| 41 | + click.echo(help_text) |
| 42 | + ctx.exit() |
| 43 | + |
| 44 | + |
| 45 | +@click.group(add_help_option=False) |
| 46 | +@click.option( |
| 47 | + "-h", |
| 48 | + "--help", |
| 49 | + is_flag=True, |
| 50 | + expose_value=False, |
| 51 | + is_eager=True, |
| 52 | + callback=_help_callback, |
| 53 | + help="Show this message and exit.", |
| 54 | +) |
12 | 55 | def cli() -> None: |
13 | 56 | pass |
14 | 57 |
|
|
0 commit comments