Class: Kramdown::Gemtext::CLI

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

Overview

CLI handled by optparse

Instance Method Summary collapse

Instance Method Details

#help(opts) ⇒ Object



22
23
24
25
26
27
# File 'lib/kramdown/gemtext/cli.rb', line 22

def help(opts)
  opts.on("-h", "--help", "This help message") do
    puts opts
    exit
  end
end

#options_other(opts) ⇒ Object



29
30
31
32
33
34
# File 'lib/kramdown/gemtext/cli.rb', line 29

def options_other(opts)
  opts.on("-o", "--other", "Do... other") do |_o|
    puts "OK"
    exit
  end
end

#start(*_args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kramdown/gemtext/cli.rb', line 8

def start(*_args)
  OptionParser.new do |opts|
    opts.banner = <<~BANNER
      Kramdown-gemtext
      Expanded help here

      Commands:
    BANNER
    help(opts)
    options_other(opts)
    version(opts)
  end.parse!
end

#version(opts) ⇒ Object



36
37
38
39
40
41
# File 'lib/kramdown/gemtext/cli.rb', line 36

def version(opts)
  opts.on("-v", "--version", "The version") do
    puts Kramdown::Gemtext::VERSION
    exit
  end
end