cmds
cmds.cr 
Yet another CLI Builder library for Crystal (0.26.1).
features
- Simple and readable syntax for command and task
- Automatic generation of command candidates
- Automatic generation of task candidates
- Around filter to commands
Usage
hello world
Writing logics into run
method provides a command.
Cmds.command "hello" do
def run
puts "Hello world!"
end
end
Cmds.run(ARGV)
$ prog hello
Hello world!
with args
args[0]
is automatically saved astask_name
args[1..-1]
can be used asargs
argN
likearg1
,arg2
is used for handy accessors
See: ./examples/args.cr
with tasks
Writing logics as task
provides sub commands.
Cmds.command "json" do
usage "pretty file.json"
task "pretty" do
path = args.shift? || abort "specify file"
puts Pretty.json(File.read(path))
end
end
Cmds.run(ARGV)
$ prog
Error: unknown command: ''
Possible commands are: ["json"]
$ prog json
Error: unknown task: ''
Possible tasks are: ["pretty"]
prog json pretty file.json
$ prog json pretty
specify file
around filter
before
and after
methods will be automatically fired.
See examples/hello.cr.
Installation
Add this to your application's shard.yml
:
dependencies:
cmds:
github: maiha/cmds.cr
version: 0.3.4
require "cmds"
Development
make test
Contributing
- Fork it (https://github.com/maiha/cmds.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- maiha maiha - creator, maintainer