Skip to content

Commit

Permalink
add rockspec, rename script for install, add version
Browse files Browse the repository at this point in the history
  • Loading branch information
1337joe committed Apr 12, 2021
1 parent e8f70f1 commit 03596bb
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Joe Rogers
Copyright (c) 2020 - 2021 Joe Rogers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

Utility to take code from multiple files and combine them into a paste-able Lua configuration for easy import into Dual Universe.

## Installing

If you'd rather install the latest release instead of cloning the repository this module can be installed through luarocks by simply running:

```sh
luarocks install du-bundler
```

This will put the bundle script on your path under the name `du-bundler`. All the following instructions apply, except that the script can be called without specifying the path to it and without the .lua extension.

## Usage

To run this bundler, simply call the file directly, passing in the template file and (optionally) output file. If no output file is specified the filled in template will be printed to stdout, which may then be piped to `xclip -selection c` on linux or `clip.exe` on windows. For a concrete example, this is how the example template can be run:

```sh
./bundleTemplate.lua example/template.json
./du-bundler.lua example/template.json
```

## Template Format
Expand All @@ -18,7 +28,7 @@ The template is basically the json representation of a controller that can be ex

Tags are delimited by `${}` and are formatted as `tagName [: arguments]`, where the tag name is case insensitive and tags that don't have arguments won't have the colon separator or anything listed after the tag name. For example, `${ARGS} : channel *` would resolve as an `ARGS` tag with arguments `channel` and `*`, as might be used to define an event handler in a receiver element.

Example tag usage may be found in the examples directory, or in `TestBundleTemplate.lua`, primarily in the "testTag<tag name>" and "testGetTagReplacement<tag name>" methods.
Example tag usage may be found in the examples directory, or in `TestBundleTemplate.lua`, primarily in the `testTag<tag name>` and `testGetTagReplacement<tag name>` methods.

#### FILE

Expand Down
25 changes: 25 additions & 0 deletions du-bundler-1.0-0.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package = "du-bundler"
version = "1.0-0"
source = {
url = "git://github.com/1337joe/du-bundler",
tag = "v1.0.0",
}
description = {
summary = "Utility to combine multiple files into a paste-able Lua configuration for easy import into Dual Universe.",
detailed = "Utility to combine multiple files into a paste-able Lua configuration for easy import into Dual Universe.",
homepage = "https://github.com/1337joe/du-mocks",
license = "MIT",
}
dependencies = {
"lua >= 5.1",
}
build = {
type = "builtin",
modules = {},
copy_directories = {},
install = {
bin = {
["du-bundler"] = "du-bundler.lua",
}
},
}
25 changes: 25 additions & 0 deletions du-bundler-scm-0.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package = "du-bundler"
version = "scm-0"
source = {
url = "git://github.com/1337joe/du-bundler",
branch = "main",
}
description = {
summary = "Utility to combine multiple files into a paste-able Lua configuration for easy import into Dual Universe.",
detailed = "Utility to combine multiple files into a paste-able Lua configuration for easy import into Dual Universe.",
homepage = "https://github.com/1337joe/du-mocks",
license = "MIT",
}
dependencies = {
"lua >= 5.1",
}
build = {
type = "builtin",
modules = {},
copy_directories = {},
install = {
bin = {
["du-bundler"] = "du-bundler.lua",
}
},
}
5 changes: 5 additions & 0 deletions bundleTemplate.lua → du-bundler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
local BundleTemplate = {}
_G.BundleTemplate = BundleTemplate

local VERSION = "1.0.0"

local TAG_KEY = "key"
local TAG_SLOT_KEY = "slotkey"
local TAG_SLOT_NAME = "slotname"
Expand Down Expand Up @@ -294,6 +296,9 @@ if not arg[1] or arg[1] == "--help" or arg[1] == "-h" then
print("If outputFile is not provided will stream results to stdout.")
-- TODO better help display, more detailed argument handling
return
elseif arg[1] == "--version" then
print(VERSION)
return;
end

local inputFile = arg[1]
Expand Down
2 changes: 1 addition & 1 deletion tests/TestBundleTemplate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local lu = require("luaunit")
-- NOTE: This expects the tests/results directory to exist before being called.
local originalArguments = _G.arg
_G.arg = {"example/template.json", "tests/results/output.json"}
dofile("bundleTemplate.lua")
dofile("du-bundler.lua")
_G.arg = originalArguments

_G.TestBundleTemplate = {}
Expand Down

0 comments on commit 03596bb

Please sign in to comment.