Project

yoptparse

0.0
No commit activity in last 3 years
No release in over 3 years
Command line option parsing with YARD and optparse.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.13
~> 10.0
= 3.5.0

Runtime

>= 0
 Project Readme

Yoptparse

Gem Version Documentation CircleCI

Command line option parsing with YARD and optparse.

Installation

Add this line to your application's Gemfile:

gem "yoptparse"

And then execute:

bundle

Or install it yourself as:

gem install yoptparse

Usage

Inherit Yoptparse::Command and define #initialize method with YARD style documentation.

class ExampleCommand < Yoptparse::Command
  # Usage example-command [options]
  # @param destination [String] Directory path to put extracted emoji images
  # @param format [String] png or svg (default: png)
  # @param provider [String] Emoji provider name (apple, emoji_one, noto or twemoji)
  # @param quiet [Boolean] Disable log output
  # @param size [Integer] Image size
  def initialize(destination:, format: "png", provider:, quiet: false, size: 64)
    @destination = destination
    @format = format
    @provider = provider
    @quiet = quiet
    @size = size
  end
end

Yoptparse::Command.to_option_parser

Returns an OptionParser instance.

puts ExampleCommand.to_option_parser
Usage: example-command [options]
        --destination=               Directory path to put extracted emoji images (required)
        --provider=                  Emoji provider name (apple, emoji_one, noto or twemoji) (required)
        --format=                    png or svg (default: png)
        --quiet                      Disable log output
        --size=                      Image size

Yoptparse::Command.parse

Create a new instance from ARGV parse result.

p ExampleCommand.parse(ARGV)
#<ExampleCommand:0x007ff6e41b8ea0 @destination="/path/to/emoji", @format="png", @provider="twemoji", @quiet=false, @size=64>

Documentation

See API documentation at http://www.rubydoc.info/github/r7kamura/yoptparse.