Class: TracWiki::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/trac-export-wiki.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



49
50
51
# File 'lib/trac-export-wiki.rb', line 49

def initialize
  self.config = DefaultConfiguration.dup
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



47
48
49
# File 'lib/trac-export-wiki.rb', line 47

def config
  @config
end

Instance Method Details

#run(*args) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/trac-export-wiki.rb', line 53

def run(*args)
  args = args.dup
  opts = OptionParser.new
  opts.banner = "Usage: trac-export-wiki [options] config.yaml"
  opts.on('-u', '--username USERNAME') {|username| config[:username] = username }
  opts.on('-p', '--password PASSWORD') {|password| config[:password] = password }
  opts.on('-b', '--base-url URL') {|url| config[:base_url] = url }
  opts.on('-t', '--wiki-title TITLE') {|title| config[:wiki_title] = title }
  opts.on('-T', '--wiki-title-prefix TITLE') {|title| config[:wiki_title_prefix] = title }
  opts.on('-i', '--only-index') { config[:only_index] = true }
  opts.on('-n', '--no-index') { config[:no_index] = true }
  opts.parse!(args)
  parse_from_yaml(args.first) if args.size > 0
  Exporter.new(config).export
end