Sha256: 8427e24190db63462244988f6890a41f9cf9dd1ef41a881795c957d1c496aa76

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

require_relative '../patricia'
require 'optparse'


module CLI

  @@options = {}

  def self.options
    @@options
  end

  OptionParser.new do |opts|
    opts.banner = 'Usage: patricia <markup-dir> [output-dir] [options]'
    opts.separator '---------------------------------------------------'
    opts.separator ''
    opts.separator 'Options:'

    opts.on('-p', '--port PORT', Integer,
            'Port to run the server on') do |v|
      options[:port] = v
    end

    opts.on('-c', '--css DIR', 'Directory with CSS files to be',
            'included in the output',
            '  (All .css files in this directory',
            '  and its subdirectories will be', '  hovered up.)') do |v|
      options[:css] = File.expand_path(v.strip)
    end

    opts.on('-j', '--js DIR', 'Directory with JavaScript files to be',
            'included in the output', '  (All .js files in this directory',
            '  and its subdirectories will be', '  hovered up.)') do |v|
      options[:js] = File.expand_path(v.strip)
    end

    opts.on('-t', '--[no-]tooltips', 'Show tooltips with filepaths when',
            '  hovering over elements in the',
            '  sidebar (default: hide)') do |v|
      options[:tooltips] = v
    end

    opts.on('-e', '--editor', 'Enable markup editor') do |v|
      options[:editor] = v
    end

    opts.on('-g', '--gfm',
            'Use GitHub Flavored Markdown for all', '  rendering') do |v|
      options[:gfm] = v
    end

    # Description

    opts.separator ''
    opts.separator 'Info:'

    opts.on_tail('-h', '--help', 'Show this message') do |v|
      puts opts
      exit
    end
    opts.on_tail('-v', '--version', 'Show the version') do |v|
      puts Patricia::VERSION
      exit
    end
  end.parse!

  @@options[:markup_dir] = ARGV.shift
  @@options[:output_dir] = ARGV.shift

  if !@@options[:markup_dir]
    puts 'ERROR: Need a markup directory'
    exit
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
patricia-0.1.2 lib/patricia/cli.rb
patricia-0.1.1 lib/patricia/cli.rb