Class: Branding::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/branding/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/branding/cli.rb', line 6

def initialize(args)
  @options = OpenStruct.new

  @options.file = args.last

  @parser = OptionParser.new do |opts|
    opts.banner = 'Usage: branding FILE'
    opts.on('-p PIXEL',
            '--pixel=PIXEL',
            [:normal, :hires, :hicolor],
            'The pixel rendering algorithm (`normal`, `hires`, or `hicolor`)') do |pixel_algo|
      @options.algo = pixel_algo.to_sym
    end

    opts.on_tail('-h', '--help', 'Show this message') do
      puts opts
      exit
    end
  end

  @parser.parse!(args)
  @options
end

Instance Method Details

#runObject



30
31
32
33
34
# File 'lib/branding/cli.rb', line 30

def run
   = Branding::.new(@options.file)
  .algo = @options.algo if @options.algo
  .print
end