Skip to content

Commit

Permalink
update readme and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
KnorrFG committed Nov 11, 2023
1 parent 68a3320 commit c2fad7b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dotree"
version = "0.5.3"
version = "0.6.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,42 @@ menu root {
By default, dotree looks at a file named `dotree.dt` in the XDG config dir, you can make
it look somewhere else with the `-c` command line argument

### Snippets

To share code between multiple commands, you can define snippets:

```
snippet shared_vars = !"
a_var=a_value
b_var=b_value
"!
menu root {
e: $shared_vars + "echo $a_var"
}
```

A snippet can be referenced by its name prefixed with a `$`. You use them in the definition
of commands or in the definition of snippets. The can occur in any order like this:

```
snippet vars = !"
FOO="foo"
"!
snippet a_fn = " # we want a newline here
append_foo() {
echo $1 foo
}
" # and here, since strings are simpli concatenated, and bash needs those newlines
# alternatively, we could use a ; in the command
menu root {
e: $vars + "echo foo=$FOO" + $a_fn + "append_foo $FOO"
}
```

## Installation

Download the appropriate binary for your platform (windows is untested) from the release page,
Expand Down
8 changes: 7 additions & 1 deletion tests/bash_tests/string_test.dt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ snippet vars = !"
FOO="foo"
"!

snippet a_fn = " # we want a newline here
append_foo() {
echo $1 foo
}
" # and here

menu root {
e: $vars + "echo foo=$FOO"
e: $vars + "echo foo=$FOO" + $a_fn + "append_foo $FOO"
}
1 change: 1 addition & 0 deletions tests/bash_tests/string_test.out
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
[?25l[?25hfoo=foo
foo foo

0 comments on commit c2fad7b

Please sign in to comment.