Sha256: 6006af14c2bbbc5dfded2f9bffa61007d070c7de47c7ff4044039df8273b1000

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

module Pione
  module Command
    # PioneVal command enables you to get evaluation result of PIONE expressions from out of PIONE system.
    class PioneVal < BasicCommand
      define_info do
        set_name "pione-val"
        set_banner "Get the evaluation result value of the PIONE expression."
      end

      define_option do
        use :debug

        define(:domain_info) do |item|
          item.long = '--domain-info=LOCATION'
          item.desc = 'location of Domain info file'
          item.default = Location["./domain.dump"]
          item.value = lambda {|location| Location[location]}
        end
      end

      start do
        # get expression string
        str = @argv.first || abort("no expressions")

        # setup domain info
        domain_info = nil
        if option[:domain_info].exist?
          domain_info = System::DomainInfo.read(option[:domain_info])
        end

        begin
          # evaluate it and print the result
          $stdout.puts Pione.val(str, domain_info)
          exit
        rescue Model::UnboundVariableError => e
          if option[:domain_info].exist?
            raise
          else
            abort("domain info file '%s' not found" % option[:domain_info].uri.to_s)
          end
        rescue => e
          abort("error: %s" % e)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pione-0.2.2 lib/pione/command/pione-val.rb
pione-0.2.1 lib/pione/command/pione-val.rb