aboutsummaryrefslogtreecommitdiff
path: root/src/create.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/create.lua')
-rw-r--r--src/create.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/create.lua b/src/create.lua
new file mode 100644
index 0000000..19ba7e8
--- /dev/null
+++ b/src/create.lua
@@ -0,0 +1,23 @@
+return function()
+ local args = require('arg') {
+ strict = false,
+ { name = "target" },
+ {
+ name = "template",
+ description = "template name or path to build.lua",
+ kind = "property",
+ required = true,
+ },
+ }
+
+ local path = manager.get(args.template) or Path:new(args.template)
+
+ if not path:exists() then
+ error('template does not exist.')
+ end
+
+ local builder = Builder:from_template(path)
+
+ local instance = builder:build(args)
+ instance:save_to(args.target)
+end