summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-11-26 23:54:03 +0200
committerPaul Buetow <paul@buetow.org>2025-11-26 23:54:03 +0200
commit8ae2053ca15e16c39e9c2aae9cc14c35f213e115 (patch)
tree2fd2ec5c36a784987950ef3140e0f1d27d2cdf6d /README.md
parentb81d86ef9a6e286efdaf7f574a105ab416928551 (diff)
update readme with some examples
Diffstat (limited to 'README.md')
-rw-r--r--README.md65
1 files changed, 65 insertions, 0 deletions
diff --git a/README.md b/README.md
index 1c65f5e..03a5ee2 100644
--- a/README.md
+++ b/README.md
@@ -15,3 +15,68 @@ rake test
cd playground
rake wireguard -- --debug
```
+
+## Examples
+
+Here are some examples of how to use the DSL.
+
+### Create a file with content
+
+```ruby
+configure do
+ file '/tmp/hello_world.txt' do
+ 'Hello World!'
+ end
+end
+```
+
+### Create a file from a template
+
+```ruby
+configure do
+ file '/tmp/calc.txt' do
+ from template
+ 'One plus two is <%= 1 + 2 %>!'
+ end
+end
+```
+
+### Add a line to a file
+
+```ruby
+configure do
+ file '/tmp/notes.txt' do
+ line 'Remember to buy milk'
+ end
+end
+```
+
+### Conditional execution
+
+```ruby
+configure do
+ given { hostname 'myserver' }
+
+ file '/etc/myserver.conf' do
+ 'config'
+ end
+end
+```
+
+### Dependency management
+
+```ruby
+configure do
+ notify 'service_restart' do
+ requires file '/etc/config.conf'
+ # ... logic to restart service
+ end
+
+ file '/etc/config.conf' do
+ 'configuration settings'
+ end
+end
+```
+
+For more examples, check out the [tests](./test/lib/dslkeywords).
+