Module: NanDoc::Cli::OptionMethods

Included in:
ExclusiveOptions, NanDoc::Commands::Diff, NanDoc::CreateNanDocSite, Erb::Agent
Defined in:
lib/nandoc/cli/option-methods.rb,
lib/nandoc/cli/option-methods/option-enum.rb

Defined Under Namespace

Classes: OptionEnum

Instance Method Summary collapse

Instance Method Details

#exclusive_opt_flags(opts, &block) ⇒ Object

only call this if you are like a ::Cri::Command object with all the nanDoc hacks. ick. This is a temprary hack. Trollop et al do this better.



9
10
11
12
# File 'lib/nandoc/cli/option-methods.rb', line 9

def exclusive_opt_flags opts, &block
  require File.dirname(__FILE__)+'/option-methods/exclusive-options.rb'
  ExclusiveOptions.new(&block).parse(self, opts)
end

#normalize_opt_key(k) ⇒ Object



24
25
26
# File 'lib/nandoc/cli/option-methods.rb', line 24

def normalize_opt_key k
  k.to_s.gsub('-','_').to_sym
end

#normalize_opts(opts) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/nandoc/cli/option-methods.rb', line 13

def normalize_opts opts
  opts = opts.dup
  opts.keys.select{|x| x.to_s.index('-') }.each do |k|
    opts[normalize_opt_key(k)] = opts.delete(k)
  end
  opts
end

#option_enumObject



20
21
22
23
# File 'lib/nandoc/cli/option-methods.rb', line 20

def option_enum
  require File.dirname(__FILE__)+'/option-methods/option-enum.rb'
  OptionEnum
end

#unnormalize_opt_key(key) ⇒ Object



30
31
32
# File 'lib/nandoc/cli/option-methods.rb', line 30

def unnormalize_opt_key key
  "--#{key.to_s.gsub('_','-')}"
end

#unnormalize_opt_keys(keys) ⇒ Object



27
28
29
# File 'lib/nandoc/cli/option-methods.rb', line 27

def unnormalize_opt_keys keys
  keys.map{|x| unnormalize_opt_key(x)}
end