Skip to content

Commit

Permalink
feat(ems/command): add ems:batch command (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei authored Jun 17, 2024
1 parent db29d64 commit 5e3ff80
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion dev/common-bundle/commands.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
# Commands

<!-- TOC -->
* [Commands](#commands)
* [Batch](#batch)
* [Clear logs](#clear-logs)
* [Example](#example)
* [Status](#status)
* [Curl](#curl)
<!-- TOC -->

## Batch

Run command(s) defined in twig template.

- The template must output a valid json list of commands.
- If the template contains a block named ```execute```, only this block will be rendered.

```
Usage:
ems:batch <template>
Arguments:
template template name, path or twig code
Options:
--context=CONTEXT context passed to twig
```

### Examples

```bash
# define template twig namespace
php bin/console ems:batch "@EMSCH/template_ems/batch.json.twig"
# define template by path
php bin/console ems:batch ../demo/skeleton/template_ems/batch.json.twig
# define template in command
php bin/console ems:batch '["ems:version", "ems:health-check]'
```
```twig
{# example batch.json.twig #}
{% block execute %}
{{ ["ems:version", "ems:health-check"]|json_encode|raw }}
{% endblock %}
```

Provide context from command to twig template

```bash
# add context
php bin/console ems:batch "@EMSCH/template_ems/batch_context.json.twig" --context='{"envName":"live"}'
```
```twig
{# example batch.json.twig #}
{% block execute %}
{{ ["ems:environment:rebuild #{envName}"]|json_encode|raw }}
{% endblock %}
```

## Clear logs

Remove stored logs from the database.
Expand Down Expand Up @@ -46,4 +103,4 @@ This command allows you to save request to a file. Usage:
ems:curl /public/view/54 /opt/samples/test.pdf --save --base-url=http://demo-admin-dev.localhost
```

In this example the request `/public/view/54` will be saved to the file `/opt/samples/test.pdf`. With the `--save` option the file will be uploaded to the storages services. And the `--base-url=http://demo-admin-dev.localhost` option will generate an url to the user. Is the `base-url` option is defined the file will be saved even if the `--save` is not specified.
In this example the request `/public/view/54` will be saved to the file `/opt/samples/test.pdf`. With the `--save` option the file will be uploaded to the storages services. And the `--base-url=http://demo-admin-dev.localhost` option will generate an url to the user. Is the `base-url` option is defined the file will be saved even if the `--save` is not specified.

0 comments on commit 5e3ff80

Please sign in to comment.