[ANN] Cri 2.0, a tool for building CLI apps

2 views
Skip to first unread message

Denis Defreyne

unread,
Jul 17, 2011, 6:39:30 AM7/17/11
to ruby-talk ML
Hi,

A while ago I released Cri 2.0, a tool for building commandline
applications, but forgot to announce it so here’s an official
announcement!

Cri allows you to define commands with options using a pretty DSL. It is
capable of building git-style commandline interfaces. Features include
nestable commands, powerful yet compact option parsing and automatically
generated online help.

Documentation is available at
<http://rubydoc.info/gems/cri/file/README.md>, and the code can be found
at <https://github.com/ddfreyne/cri>.

Here is an example of a Cri command:

command = Cri::Command.define do
name 'dostuff'
usage 'dostuff [options]'
aliases :ds, :stuff
summary 'does stuff'
description 'This command does a lot of stuff. I really mean a lot.'

flag :h, :help, 'show help for this command' do |value, cmd|
puts cmd.help
exit 0
end
flag :m, :more, 'do even more stuff'
option :s, :stuff, 'specify stuff to do', :argument => :required

run do |opts, args, cmd|
stuff = opts[:stuff] || 'generic stuff'
puts "Doing #{stuff}!"

if opts[:more]
puts 'Doing it even more!'
end
end
end

Cri 2.0 differs from Cri 1.0 in that it is simpler and adds a clean DSL
for defining commands. Cri 1.0 has been used in production for nanoc
(http://nanoc.stoneship.org/) for quite a while, and Cri 2.0 will be
used for the upcoming nanoc 3.2 release.

Cheers,

Denis

--
Posted via http://www.ruby-forum.com/.

Reply all
Reply to author
Forward
0 new messages