From c07697abf892eafafc4e5eeb7a3ae1492f9b578f Mon Sep 17 00:00:00 2001 From: Jake Deichert Date: Mon, 10 Aug 2020 21:13:01 -0400 Subject: [PATCH] Document subcommands without prefixing --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 45792eb..98c0059 100644 --- a/README.md +++ b/README.md @@ -178,13 +178,13 @@ Important to note that `mask` auto injects a very common `boolean` flag called ` ### Subcommands -Nested command structures can easily be created since they are simply defined by the level of markdown heading. H2 (`##`) is where you define your top-level commands. Every level after that is a subcommand. The only requirement is that subcommands must have all ancestor commands present in their heading. +Nested command structures can easily be created since they are simply defined by the level of markdown heading. H2 (`##`) is where you define your top-level commands. Every level after that is a subcommand. **Example:** ```markdown ## services -> Commands related to starting, stopping, and restarting services +> Commands related to starting and stopping services ### services start (service_name) @@ -203,6 +203,31 @@ echo "Stopping service $service_name" ~~~ ``` +You may notice above that the `start` and `stop` commands are prefixed with their parent command `services`. Prefixing subcommands with their ancestor commands may help readability in some cases, however, it is completely optional. The example below is the same as above, but without prefixing. + +**Example:** +```markdown +## services + +> Commands related to starting and stopping services + +### start (service_name) + +> Start a service. + +~~~bash +echo "Starting service $service_name" +~~~ + +### stop (service_name) + +> Stop a service. + +~~~bash +echo "Stopping service $service_name" +~~~ +``` + ### Support for other scripting runtimes On top of shell/bash scripts, `mask` also supports using node, python, ruby and php as scripting runtimes. This gives you the freedom to choose the right tool for the specific task at hand. For example, let's say you have a `serve` command and a `snapshot` command. You could choose python to `serve` a simple directory and maybe node to run a puppeteer script that generates a png `snapshot` of each page.