diff options
Diffstat (limited to 'tests/encode.lua')
| -rwxr-xr-x | tests/encode.lua | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/encode.lua b/tests/encode.lua index e8026cc..f13787c 100755 --- a/tests/encode.lua +++ b/tests/encode.lua | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | #!/usr/bin/env lua | 1 | #!/usr/bin/env lua |
| 2 | 2 | ||
| 3 | -- usage: encode.lua [lua_file] | ||
| 4 | -- | ||
| 5 | -- Eg: | ||
| 6 | -- echo '{ "testing" }' | ./encode.lua | ||
| 7 | -- ./encode.lua lua_data.lua | ||
| 8 | |||
| 3 | require "common" | 9 | require "common" |
| 4 | require "cjson" | 10 | require "cjson" |
| 5 | 11 | ||
| @@ -16,11 +22,7 @@ function get_lua_table(file) | |||
| 16 | return env.data | 22 | return env.data |
| 17 | end | 23 | end |
| 18 | 24 | ||
| 19 | if not arg[1] then | 25 | local t = get_lua_table(arg[1]) |
| 20 | print("usage: encode.lua FILE") | 26 | print(cjson.encode(t)) |
| 21 | os.exit(-1) | ||
| 22 | end | ||
| 23 | |||
| 24 | print(cjson.encode(get_lua_table(arg[1]))) | ||
| 25 | 27 | ||
| 26 | -- vi:ai et sw=4 ts=4: | 28 | -- vi:ai et sw=4 ts=4: |
