Skip to content

r7kamura/yoptparse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Command line option parsing with YARD and optparse.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages