Class: WMLAction::CLI

Inherits:
Thor
  • Object
show all
Includes:
Log
Defined in:
lib/wml_action/cli.rb

Instance Method Summary collapse

Methods included from Log

#level=, #log

Instance Method Details

#action_read(filename) ⇒ Object



46
47
48
49
50
51
# File 'lib/wml_action/cli.rb', line 46

def action_read(filename)
    log.level=Logger::INFO if options[:verbose]
    log.level=Logger::DEBUG if options[:debug]
    d=Document.from_file(filename)
    print d.root.to_s
end

#modify(original, modlist) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/wml_action/cli.rb', line 13

def modify(original,modlist)
    log.level=Logger::INFO if options[:verbose]
    log.level=Logger::DEBUG if options[:debug]

    target_name=original
    modlist_name=modlist

    unless File.exist?(target_name)
            log.fatal "Invalid target file: #{target_name}"
            exit
    end
    unless File.exist?(modlist_name)
            log.fatal "Invalid modlist file: #{modlist_name}"
            exit
    end

    target=Document.from_file(target_name)
    modlist=Document.from_file(modlist_name)

    target.root.merge(modlist.root)
    print target.root.to_s

end

#read(filename) ⇒ Object



38
39
40
41
42
43
# File 'lib/wml_action/cli.rb', line 38

def read(filename)
    log.level=Logger::INFO if options[:verbose]
    log.level=Logger::DEBUG if options[:debug]
    d=Document.from_file(filename)
    print d.root.to_s
end