MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / execute

Method execute

ruby/engine/openstudio_cli.rb:1381–1597  ·  view source on GitHub ↗

Executes code to update and compute arguments for measures @param [Array] sub_argv Options passed to the e command from the user input @return [Fixnum] Return status

(sub_argv)

Source from the content-addressed store, hash-verified

1379 # @return [Fixnum] Return status
1380 #
1381 def execute(sub_argv)
1382
1383 $logger.info "Measure, sub_argv = #{sub_argv}"
1384
1385 require_relative 'measure_manager'
1386
1387 options = {}
1388 options[:update] = false
1389 options[:compute_arguments] = nil
1390
1391 # save some arguments to pass to minitest
1392 saved_subargv = []
1393 if sub_argv[0] == '-r' || sub_argv[0] == '--run_tests'
1394 saved_subargv = sub_argv[2..-1]
1395 sub_argv = sub_argv[0...2]
1396 end
1397
1398 # find the directory
1399 directory = nil
1400 if sub_argv.size > 1
1401 unless (sub_argv[0] == '-s' || sub_argv[0] == '--start_server')
1402 directory = sub_argv.pop
1403 $logger.debug("Directory to examine is #{directory}")
1404 $logger.debug("Remaining args are #{sub_argv}")
1405 end
1406 end
1407
1408 opts = OptionParser.new do |o|
1409 o.banner = 'Usage: openstudio measure [options] DIRECTORY'
1410 o.separator ''
1411 o.separator 'Options:'
1412 o.separator ''
1413
1414 o.on('-t', '--update_all', 'Update all measures in a directory') do
1415 options[:update_all] = true
1416 end
1417 o.on('-u', '--update', 'Update the measure.xml') do
1418 options[:update] = true
1419 end
1420 o.on('-a', '--compute_arguments [MODEL]', 'Compute arguments for the given OSM or IDF') do |model_file|
1421 options[:compute_arguments] = true
1422 options[:compute_arguments_model] = model_file
1423 end
1424 o.on('-r', '--run_tests', 'Run all tests recursively found in a directory, additional arguments are passed to minitest') do
1425 options[:run_tests] = true
1426 end
1427 o.on('-s', '--start_server [PORT]', 'Start a measure manager server') do |port|
1428 options[:start_server] = true
1429 options[:start_server_port] = port
1430 end
1431 # TODO: run unit tests
1432 end
1433
1434 # Parse the options
1435 argv = parse_options(opts, sub_argv)
1436 return 0 if argv == nil
1437
1438 $logger.debug("Measure command: #{argv.inspect} #{options.inspect}")

Callers

nothing calls this directly

Calls 15

parse_optionsFunction · 0.85
safe_putsFunction · 0.85
infoMethod · 0.80
debugMethod · 0.80
expand_pathMethod · 0.80
globMethod · 0.80
directory?Method · 0.80
get_measureMethod · 0.80
generateMethod · 0.80
valueNameMethod · 0.80
get_idfMethod · 0.80
get_measure_infoMethod · 0.80

Tested by

no test coverage detected