Idea: Support --- yaml frontmatter in custom commands for Annotations
Just an idea that I had while parsing the custom commands docs.
It would be nicer to write:
#!/usr/bin/env bash
## Frontmatter
<<'---'
description: 'Run MySQLWorkbench against current db'
usage: mysqlworkbench
example: 'ddev mysqlworkbench'
flags:
flag:
usage: 'sets the flag option'
---
echo "Hello"
The : <<'---' is a trick to redirect the output to an empty command.
The following is also possible:
#!/usr/bin/env bash
## Frontmatter
<<---
description: 'Run MySQLWorkbench against current db'
usage: mysqlworkbench
example: 'ddev mysqlworkbench'
flags:
flag:
usage: 'sets the flag option'
---
echo "Hello"
But if the standard delimiters are not needed it could also be:
#!/usr/bin/env bash
## Frontmatter
: <<YAML_MATTER
description: 'Run MySQLWorkbench against current db'
usage: mysqlworkbench
example: 'ddev mysqlworkbench'
flags:
flag:
usage: 'sets the flag option'
YAML_MATTER
echo "Hello"
Edit, seems the preferred way is:
#!/usr/bin/env bash
<<'###FRONTMATTER'
description: 'Run MySQLWorkbench against current db'
usage: mysqlworkbench
example: 'ddev mysqlworkbench'
flags:
flag:
usage: 'sets the flag option'
###FRONTMATTER
echo "Hello"
Edit 2: One more variation that's parseable with a standard frontmatter parser (if garbage before is ignored):
#!/usr/bin/env bash
<<'###COMMENT'
---
description: 'Run MySQLWorkbench against current db'
usage: mysqlworkbench
example: 'ddev mysqlworkbench'
flags:
flag:
usage: 'sets the flag option'
---
###COMMENT
echo "Hello"
This was actually in your plans, right @gilbertsoft ?
Yes, working already on this. Will go into https://github.com/drud/ddev/pull/2519
Oh nice! 👍
Will also provide an updater which will change all your custom commands to the new format on the fly. I guess this will be a great improvement for the custom commands.
Well, it might give you some ideas for a proper prelude in any case :)
Unfortunately, #2519 never reached maturity :(