mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
added version flag
This commit is contained in:
parent
859c033cb0
commit
79b7cc25e5
11
moon
11
moon
@ -4,15 +4,15 @@ require "alt_getopt"
|
|||||||
require "moonscript.errors"
|
require "moonscript.errors"
|
||||||
require "moonscript"
|
require "moonscript"
|
||||||
|
|
||||||
|
|
||||||
-- moonloader and repl
|
-- moonloader and repl
|
||||||
local opts, ind = alt_getopt.get_opts(arg, "chd", { help = "h" })
|
local opts, ind = alt_getopt.get_opts(arg, "cvhd", { version = "v", help = "h" })
|
||||||
|
|
||||||
local help = [=[Usage: %s [options] [script [args]]
|
local help = [=[Usage: %s [options] [script [args]]
|
||||||
|
|
||||||
-c Compile in memory, don't write .lua files
|
-c Compile in memory, don't write .lua files
|
||||||
-h Print this message
|
-h Print this message
|
||||||
-d Disable stack trace rewriting
|
-d Disable stack trace rewriting
|
||||||
|
-v Print version
|
||||||
]=]
|
]=]
|
||||||
|
|
||||||
local function print_help(err)
|
local function print_help(err)
|
||||||
@ -23,6 +23,13 @@ end
|
|||||||
|
|
||||||
if opts.h then print_help() end
|
if opts.h then print_help() end
|
||||||
|
|
||||||
|
if opts.v then
|
||||||
|
local v = require "moonscript.version"
|
||||||
|
v.print_version()
|
||||||
|
os.exit()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local script_fname = arg[ind]
|
local script_fname = arg[ind]
|
||||||
if not script_fname then
|
if not script_fname then
|
||||||
print_help("repl not yet supported")
|
print_help("repl not yet supported")
|
||||||
|
9
moonc
9
moonc
@ -9,15 +9,22 @@ require "moonscript.util"
|
|||||||
require "alt_getopt"
|
require "alt_getopt"
|
||||||
require "lfs"
|
require "lfs"
|
||||||
|
|
||||||
local opts, ind = alt_getopt.get_opts(arg, "hwt:", { help = "h" })
|
local opts, ind = alt_getopt.get_opts(arg, "vhwt:", { version = "v", help = "h" })
|
||||||
|
|
||||||
local help = [[Usage: %s [options] file...
|
local help = [[Usage: %s [options] file...
|
||||||
|
|
||||||
-h Print this message
|
-h Print this message
|
||||||
-w Watch file/directory
|
-w Watch file/directory
|
||||||
-t path Specify where to place compiled files
|
-t path Specify where to place compiled files
|
||||||
|
-v Print version
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
if opts.v then
|
||||||
|
local v = require "moonscript.version"
|
||||||
|
v.print_version()
|
||||||
|
os.exit()
|
||||||
|
end
|
||||||
|
|
||||||
function print_help(err)
|
function print_help(err)
|
||||||
if err then print("Error: "..err) end
|
if err then print("Error: "..err) end
|
||||||
print(help:format(arg[0]))
|
print(help:format(arg[0]))
|
||||||
|
@ -32,6 +32,7 @@ build = {
|
|||||||
["moonscript.util"] = "moonscript/util.lua",
|
["moonscript.util"] = "moonscript/util.lua",
|
||||||
["moonscript.init"] = "moonscript/init.lua",
|
["moonscript.init"] = "moonscript/init.lua",
|
||||||
["moonscript.errors"] = "moonscript/errors.lua",
|
["moonscript.errors"] = "moonscript/errors.lua",
|
||||||
|
["moonscript.version"] = "moonscript/version.lua",
|
||||||
},
|
},
|
||||||
install = {
|
install = {
|
||||||
bin = { "moon", "moonc" }
|
bin = { "moon", "moonc" }
|
||||||
|
7
moonscript/version.lua
Normal file
7
moonscript/version.lua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
module("moonscript.version", package.seeall)
|
||||||
|
|
||||||
|
version = "0.1.0"
|
||||||
|
function print_version()
|
||||||
|
print("MoonScript version "..version)
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user