Skip to content

Commit

Permalink
Change required arguments to use (round_brackets) instead of <angle_b…
Browse files Browse the repository at this point in the history
…rackets>

Fixes #15

Although it's quite obvious, I didn't even think about angle brackets causing a problem with renderers. I thought I saw them working within headings and not being parsed as html...

Round brackets work nice.
[square_brackets] will be used for optional args.
  • Loading branch information
jacobdeichert committed Jul 19, 2019
1 parent 266d4cb commit b9ea0e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ mask test

### Positional arguments

These are defined beside the command name within `<angle_brackets>`. They are required arguments that must be supplied for the command to run. [Optional args][2] are coming soon. The argument name is injected into the script's scope as an environment variable.
These are defined beside the command name within `(round_brackets)`. They are required arguments that must be supplied for the command to run. [Optional args][2] are coming soon. The argument name is injected into the script's scope as an environment variable.

**Example:**

```markdown
## test <file> <test_case>
## test (file) (test_case)

> Run tests

Expand Down Expand Up @@ -129,15 +129,15 @@ Nested command structures can easily be created since they are simply defined by

> Commands related to starting, stopping, and restarting services

### services start <service_name>
### services start (service_name)

> Start a service.

~~~bash
echo "Starting service $service_name"
~~~

### services stop <service_name>
### services stop (service_name)

> Stop a service.

Expand All @@ -161,7 +161,7 @@ On top of shell/bash scripts, `mask` also supports using node, python, ruby and
**Example:**

```markdown
## shell <name>
## shell (name)

> An example shell script

Expand All @@ -173,7 +173,7 @@ echo "Hello, $name!"
~~~


## node <name>
## node (name)

> An example node script

Expand All @@ -185,7 +185,7 @@ console.log(`Hello, ${name}!`);
~~~


## python <name>
## python (name)

> An example python script

Expand All @@ -200,7 +200,7 @@ print("Hello, " + name + "!")
~~~


## ruby <name>
## ruby (name)

> An example ruby script

Expand All @@ -213,7 +213,7 @@ puts "Hello, #{name}!"
~~~


## php <name>
## php (name)

> An example php script

Expand Down
12 changes: 6 additions & 6 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ fn parse_command_name_and_required_args(
// and level 2 can't be a subcommand so no need to split.
let name = if heading_level > 2 {
// Takes a subcommand name like this:
// "#### db flush postgres <required_arg>"
// and returns "postgres <required_arg>" as the actual name
// "#### db flush postgres (required_arg_name)"
// and returns "postgres (required_arg_name)" as the actual name
text.clone()
.split(" ")
.collect::<Vec<&str>>()
Expand All @@ -199,8 +199,8 @@ fn parse_command_name_and_required_args(
text.clone()
};

// Find any required arguments. They look like this: <required_arg_name>
let name_and_args: Vec<&str> = name.split(|c| c == '<' || c == '>').collect();
// Find any required arguments. They look like this: (required_arg_name)
let name_and_args: Vec<&str> = name.split(|c| c == '(' || c == ')').collect();
let (name, args) = name_and_args.split_at(1);
let name = name.join(" ").trim().to_string();
let mut required_args: Vec<RequiredArg> = vec![];
Expand All @@ -225,15 +225,15 @@ const TEST_MASKFILE: &str = r#"
This is an example maskfile for the tests below.
## serve <port>
## serve (port)
> Serve the app on the `port`
~~~bash
echo "Serving on port $port"
~~~
## node <name>
## node (name)
> An example node script
Expand Down
16 changes: 8 additions & 8 deletions test/maskfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!-- Cmd description goes here. -->
> Commands related to starting, stopping, and restarting services
### services start <service_name>
### services start (service_name)

> Start or restart a service.
Expand All @@ -20,7 +20,7 @@ echo "Starting service $service_name"
~~~


### services stop <service_name>
### services stop (service_name)

> Stop a service.
Expand Down Expand Up @@ -65,15 +65,15 @@ echo "Flushed postgres"
echo "Flushed redis"
~~~

### db snapshot <snapshot_name>
### db snapshot (snapshot_name)

> Take a snapshot of the database.
~~~bash
echo "Saved db snapshot as '$snapshot_name'"
~~~

### db restore <snapshot_name>
### db restore (snapshot_name)

> Restore the database to a snapshot.
Expand Down Expand Up @@ -111,7 +111,7 @@ server.listen(PORT, () => {



## input <arg1> <arg2>
## input (arg1) (arg2)

> Example of how to accept user input and sleep
Expand Down Expand Up @@ -152,7 +152,7 @@ fi



## python <name>
## python (name)

> An example python script
Expand All @@ -168,7 +168,7 @@ print("Hello, " + name + "!")



## ruby <name>
## ruby (name)

> An example ruby script
Expand All @@ -182,7 +182,7 @@ puts "Hello, #{name}!"



## php <name>
## php (name)

> An example php script
Expand Down

0 comments on commit b9ea0e4

Please sign in to comment.