Sha256: f45478f4d472bcb45a4c1e4fdb8c4e51b0ec528a8a40b80b70cb6e26d6500261

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

require "optparse"

module Kramdown::Gemtext
  # CLI handled by optparse
  class CLI
    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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kramdown-gemtext-0.1.0 lib/kramdown/gemtext/cli.rb