Skip to content

Commit

Permalink
Document subcommands without prefixing
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdeichert committed Aug 11, 2020
1 parent fb7c48c commit c07697a
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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.
Expand Down

0 comments on commit c07697a

Please sign in to comment.