(env: Environment)
| 71 | @cli.command(name="list", help="List forms") |
| 72 | @pass_env |
| 73 | def list_forms(env: Environment): |
| 74 | form_doc = _validate_form(env) |
| 75 | for form in form_doc.forms: |
| 76 | form_title = f":downwards_button: [{FORM_NAME_STYLE}]{escape(form.name)}[/{FORM_NAME_STYLE}]" |
| 77 | if form.display_name: |
| 78 | form_title += f" [{FORM_DISPLAY_NAME_STYLE}]({escape(form.display_name)})[/{FORM_DISPLAY_NAME_STYLE}]" |
| 79 | rich.print(form_title) |
| 80 | |
| 81 | table = Table( |
| 82 | title="Fields", box=box.SIMPLE, header_style=TABLE_HEADER_STYLE, expand=True |
| 83 | ) |
| 84 | table.add_column("Name", style=TABLE_COLUMN_STYLE) |
| 85 | table.add_column("Display Name", style=TABLE_COLUMN_STYLE) |
| 86 | table.add_column("Type", style=TABLE_COLUMN_STYLE) |
| 87 | table.add_column("Required", style=TABLE_COLUMN_STYLE) |
| 88 | table.add_column("Default", style=TABLE_COLUMN_STYLE) |
| 89 | for field in form.fields: |
| 90 | table.add_row( |
| 91 | escape(field.name), |
| 92 | escape(field.display_name) if field.display_name else None, |
| 93 | escape(field.type.value), |
| 94 | str(field.required), |
| 95 | escape(field.default) if field.default else None, |
| 96 | ) |
| 97 | rich.print(Padding(table, (1, 0, 0, 4))) |
| 98 | |
| 99 | table = Table( |
| 100 | title="Operations", |
| 101 | box=box.SIMPLE, |
| 102 | header_style=TABLE_HEADER_STYLE, |
| 103 | expand=True, |
| 104 | ) |
| 105 | table.add_column("Type", style=TABLE_COLUMN_STYLE) |
| 106 | table.add_column("File", style=TABLE_COLUMN_STYLE) |
| 107 | table.add_column("Content", style=TABLE_COLUMN_STYLE) |
| 108 | for operation in form.operations: |
| 109 | table.add_row( |
| 110 | escape(operation.type), |
| 111 | escape(operation.file), |
| 112 | escape(operation.content), |
| 113 | ) |
| 114 | rich.print(Padding(table, (1, 0, 0, 4))) |
| 115 | |
| 116 | |
| 117 | @cli.command(name="server", help="Run a web server for form input") |
nothing calls this directly
no test coverage detected