<commit_before># === Synopsis:
#   RightScale run state reporter (rs_state) - (c) 2014 RightScale Inc
#
#   Report current run state of an instance
#
# === Examples:
#   Print the run state:
#   rs_state --type=run
#   Possible values: booting, booting:reboot, operational, stranded,
#                    shutting-down:reboot, shutting-down:terminate, shutting-down:stop
#
#   Print the agent state:
#   rs_state --type=agent
#   Possible values: pending, booting, operational, stranded, decommissioning, decommissioned
#
# === Usage
#    rs_state --type <type>
#
#    Options:
#      --type, -t TYPE  Display desired state(run or agent)
#      --help:          Display help
#      --version:       Display version information
#
#
require 'trollop'
require 'right_agent'
require File.normalize_path(File.join(File.dirname(__FILE__), 'command_helper'))
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'json_utilities'))
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'agent_config'))
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'instance_state'))
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'shutdown_request'))

module RightScale

  class RightLinkStateController
    include CommandHelper

    def self.run
      m = RightLinkStateController.new
      m.control(m.parse_args)
    end

    def control(options)
      name = "get_instance_state_#{options[:type]}"
      result = JSON.load(send_command({ :name => name}, options[:verbose]))
      fail(result['error']) if result['error']
      puts result['result']
    end

    def parse_args
      parser = Trollop::Parser.new do
        opt :type, "", :type => :string
        version ""
      end
      parse do
        options = parser.parse
        fail("No type specified on the command line.") unless options[:type]
        fail("Unknown state type '#{options[:type]}'. Use 'run' or 'agent'") unless ['run', 'agent'].include?(options[:type])
        options
      end
    end

    def usage
      Usage.scan(__FILE__)
    end

    def version
      "rs_state #{right_link_version} - RightLink's run state reporter(c) 2014 RightScale"
    end
  end
end
<commit_msg>acu161225 fix rs_state help<commit_after># === Synopsis:
#   RightScale run state reporter (rs_state) - (c) 2014 RightScale Inc
#
#   Report current run state of an instance
#
# === Examples:
#   Print the run state:
#   rs_state --type run
#   Possible values: booting, booting:reboot, operational, stranded,
#                    shutting-down:reboot, shutting-down:terminate, shutting-down:stop
#
#   Print the agent state:
#   rs_state --type agent
#   Possible values: pending, booting, operational, stranded, decommissioning, decommissioned
#
# === Usage
#    rs_state --type <type>
#
#    Options:
#      --type, -t TYPE  Display desired state(run or agent)
#      --help:          Display help
#      --version:       Display version information
#
#
require 'trollop'
require 'right_agent'
require File.normalize_path(File.join(File.dirname(__FILE__), 'command_helper'))
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'json_utilities'))
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'agent_config'))
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'instance_state'))
require File.normalize_path(File.join(File.dirname(__FILE__), '..', 'lib', 'instance', 'shutdown_request'))

module RightScale

  class RightLinkStateController
    include CommandHelper

    def self.run
      m = RightLinkStateController.new
      m.control(m.parse_args)
    end

    def control(options)
      name = "get_instance_state_#{options[:type]}"
      result = JSON.load(send_command({ :name => name}, options[:verbose]))
      fail(result['error']) if result['error']
      puts result['result']
    end

    def parse_args
      parser = Trollop::Parser.new do
        opt :type, "", :type => :string
        version ""
      end
      parse do
        options = parser.parse
        fail("No type specified on the command line.") unless options[:type]
        fail("Unknown state type '#{options[:type]}'. Use 'run' or 'agent'") unless ['run', 'agent'].include?(options[:type])
        options
      end
    end

    def usage
      Usage.scan(__FILE__)
    end

    def version
      "rs_state #{right_link_version} - RightLink's run state reporter(c) 2014 RightScale"
    end
  end
end

{'fraction_non_alphanumeric': 0.13525305410122165, 'fraction_numerical': 0.004799301919720768, 'mean_word_length': 3.4086538461538463, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2856058', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1373, 'n_words': 359}