0.0
No commit activity in last 3 years
No release in over 3 years
A small command line interface library for quickly building cli apps.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
 Project Readme

CLI

A small command line interface library for quickly building cli apps.

Usage

Add this to your Gemfile:

gem 'avalanche-cli', :git => 'git://github.com/avalanche123/cli.git'

Build a single command script:

#!/usr/bin/env ruby

require 'bundler/setup'
require 'avalanche/cli'

cmd = Avalanche::CLI::Command.new('hello [options] NAME', {
  :title => ['--title TITLE', String, 'Desired title']
}, Proc.new do |opts, args|
  raise "NAME is required" if args.empty?

  puts "Hello, #{opts[:title]} #{args.first}!".gsub(/\s+/, " ")
end)

cmd.run(ARGV)

Build a cli application with many subcommands:

#!/usr/bin/env ruby

require 'bundler/setup'
require 'avalanche/cli'

app = Avalanche::CLI::Application.new('app', '0.1.0')

app.command('hello [options] NAME', "Says Hello", {
  :title => ['--title TITLE', String, 'Desired title']
}, Proc.new do |opts, args|
  raise "NAME is required" if args.empty?

  puts "Hello, #{opts[:title]} #{args.first}!".gsub(/\s+/, " ")
end)

app.run(ARGV)

Check it:

> /path/to/command --help

License

MIT

Bitdeli Badge