Project

argparse

0.0
The project is in a healthy, maintained state
A gem for parsing command line arguments
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ArgParse

A gem for parsing command-line arguments.

Usage:

require "argparse"

o = { # options prefixed with --
  asd: { has_argument: false }, # option with no arguments
  qwe: { has_argument: true } # option with arguments
}

s = { # switched prefixed with -
  q: { has_argument: true }, # switch with arguments
  a: { has_argument: false } # switch without arguments
}

x=ArgsParser::Args.new(options: o, switches: s)

Running it:

$ ruby example.rb data --asd --qwe aaa -a -qa "more data"

To get args:

x.switches[:q] # => a
x.switches[:a] # => true
x.options[:asd] # => true
x.options[:qwe] # => aaa

x.data.to_s # => ["data", "more data"]