aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-04-20 14:47:58 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-04-20 14:47:58 +0200
commit96e11c169cde65194c1136e6b40c1bbea35c813a (patch)
tree29abfee5f3e8f37a53ae4f674b926f497827d963 /README.md
parent0686b40f979f4607b3fd8cca21c463e98f617666 (diff)
create cli
Diffstat (limited to 'README.md')
-rw-r--r--README.md76
1 files changed, 76 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..20781d1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,76 @@
+# Blueprint
+
+Write your project templates using lua.
+
+## Creating your own templates
+
+A _template_ is just a directory containing at least one `build.lua` file
+which describes to structure of the template. Then you can add files and directories
+that should be created when creating a instance of the template.
+
+Here is a simple example:
+
+```lua
+-- build.lua
+local template = Template:new()
+
+template:add_file("./test.py", {
+ module = "a_module_that_is_different",
+ name = template:option('name')
+})
+
+return template
+```
+
+Then the same directory will contain the `test.py` we added in the template:
+
+```py
+#!/usr/bin/env python3
+
+# This module is called @{name()}
+
+import @{module}
+
+print("@{function()
+ return "Hello World"
+end}")
+
+print("@{function()
+ local a = { "asdf", "1234" }
+ return a[1]
+end}")
+
+print(@{function()
+ local a = { "asdf", "1234" } -- {
+ return a[2]
+end})
+
+print("@{function()
+ local a = "asdf{asdf"
+ return a:sub(1)
+end}")
+
+print("@{function()
+ local a = "asdf"
+ --[[
+ some comment }
+ --]]
+ return a
+end}")
+
+print("@{function()
+ local a = [[
+ some comment }
+ ]]
+ return a:sub(2, 8)
+end}")
+```
+
+As you can see you can now run lua-code inside of the `@{...}` sections.
+The last table argument of the `add_file` function are functions or values you want to bind to the global scope of the macros and you want to use inside of the template file.
+
+### Creating additional options
+
+You can create additional command line arguments by calling `template:option('<name of your argument>')`. This returns a function which you can bind to the scripting environment like we did in the example above with the _name_ option.
+
+If you want to set a default value for an option, make it not required or add a description you can do that with the `template:set_option('<name of your argument>', '<description>', '<default value>', '<required>')` function.