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

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/.