Project

argh

0.0
No commit activity in last 3 years
No release in over 3 years
Easy command-line argument building in Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

argh

Build Status

It can be a huge pain to build arguments for an external service. There's all of those annoying escaping issues, and you just shouldn't have to deal with that crap.

Argh makes it easy to define how to serialize those attributes.

Installation

gem install argh

Usage

Just include Argh::Attributable into any Ruby class, and you're off to the races.

class Thing

  include Argh::Attributable

  argh 'command_attributes' do
    attribute(:name)
    attribute(:reverse_name) { name.reverse }
		attribute(:direct, 'value')
  end

  private

  def name
    'Heyoo'
  end

end

Thing.new.command_attributes # "-name 'Heyoo' -reverse_name 'ooyeH' -direct 'value'"

The default formatter is built to work with and properly escape arguments for JCommander, but it's very easy to add and use your own formatters (and contribute them). For an example, check out the JCommanderFormatter implementation. To use them, you can just pass a second argument to argh, like:

argh 'your_name', SomeOtherFormatter do
	# ...
end

License

See LICENSE