Sha256: e1875dc52cd02108a60f3b12ab367be0e99f74f93a0e88ace76f8ce516c1c1eb

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

require 'thor'
require 'wml_action'

module WMLAction

    class CLI < Thor
      include Log

      class_option :verbose, type: :boolean, aliases: '-v'
      class_option :debug, type: :boolean, aliases: '-d'

        desc "modify FILE MODS_FILE", "Modifies a WML"
        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

        desc "read FILE", "Reads and outputs a wml"
        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

        desc "action_read FILE", "Reads and outputs an action wml"
        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

    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wml_action-0.0.3 lib/wml_action/cli.rb
wml_action-0.0.2 lib/wml_action/cli.rb