Sha256: 752dac39eddb38196fa34329228ae1c44d059953bc0de7b46fb1e7a3764509e2
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
require 'optparse' module Artii class CLI attr_accessor :params, :action def initialize(*args) @params = {} @action = :output OptionParser.new do |opts| opts.banner = "Usage: artii 'your string here' [-f FONT_NAME or --font FONT_NAME] [-l or --list]" opts.on('-f', '--font FONT_NAME', 'Specify the font to be used (defaults to "big")') do |font| @params[:font] = font end opts.on('-l', '--list', 'Prints the list of available fonts') do |list| @action = :list_all_fonts end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end if args.empty? puts opts exit end end.parse!(args) @params[:text] = args.join " " @a = Artii::Base.new(@params) end def font_name @a.font_name end def output if @action == :output @a.send @action, @params[:text] else @a.send @action end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
artii-2.0.2 | lib/artii/cli.rb |
artii-2.0.1 | lib/artii/cli.rb |
artii-2.0.0 | lib/artii/cli.rb |