Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

lua-click

一个用于快速创建命令行程序的Lua模块。该项目从python库click借鉴了不少灵感,项目名也沿用了"click"这一缩写(Command Line Interface Creation Kit)。

Dependencies

唯一的依赖就是:

  • lua >= 5.1

该模块已在lua-5.1.5, lua-5.2.4, lua-5.3.5下验证通过。

Quick start

一个简单的HelloWorld程序:

-- HelloWorld.lua

local function main(cmd, options, arguments)
    print(string.format("Hi, %s!", arguments["name"]))
    if options["speaker"]~=nil then
        print(string.format("%40s", "-- from " .. options["speaker"]))
    end
end

local cli = require("click")

local mainCommand = cli.FunctionCommand {
    desc = "Say hi to somebody.",
    options = {
        {"-s, --speaker", help="Specify the name of speaker."},
    },
    arguments = {
        {name="name", help="Your name."},
    },
    entry_func = main,
}

if cli.__name__()=="__main__" then
    cli.main(mainCommand, nil, arg)
end

About

A Lua package for creating beautiful command line interfaces in a composable way.

Topics

Resources

License

Packages

No packages published