argvector.rb

Path: lib/more/facets/argvector.rb
Last Update: Thu Jun 24 13:18:25 +0000 2010

ArgVector

Synopsis

ArgVector provides a very simple means of parsing command line arguments.

Unlike other more complex libs this provides only the most basic and standard parsing functionality. In many cases that‘s all one really needs.

Usage is straight foward. Simply instantiate the class and query it for the particular "views" of the command line you want.

  cargs = ArgVector.new("-a foo -b=2")

  cargs.parameters    #=> [['foo'],{'a'=>true,'b'=>'2'}]
  cargs.flags         #=> ['a']
  cargs.preoptions    #=> {'a'=>true}
  cargs.preflags      #=> ['a']
  cargs.subcommand    #=> ['foo',{'b'=>'2'}]

Authors

  • Thomas Sawyer

Copying

Copyright (c) 2006 Thomas Sawyer

Ruby License

This module is free software. You may use, modify, and/or redistribute this software under the same terms as Ruby.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Required files

shellwords  

[Validate]