Class: Options::ReceiverOptionParser
- Inherits:
-
SRCommonOptionParser
- Object
- BasicOptionParser
- SRCommonOptionParser
- Options::ReceiverOptionParser
- Defined in:
- lib/options/receiver_option_parser.rb
Overview
Option parser of basic (see Options::BasicOptionParser), common (see Options::SRCommonOptionParser) and specific options for receiver client
Specific receiver options
- count
-
number of messages to receiver (default: DEFAULT_COUNT, see Defaults)
- process-reply-to
-
send message to reply-to address if enabled and message got reply-to address
- recv-browse
-
browse messages instead of reading (default: DEFAULT_BROWSE, see Defaults)
Instance Attribute Summary
Attributes inherited from BasicOptionParser
Instance Method Summary collapse
-
#initialize(args) ⇒ ReceiverOptionParser
constructor
- Initialization and parsing of basic, common and specific receiver options ==== Parameters args
-
arguments to parse.
Methods inherited from SRCommonOptionParser
Methods inherited from BasicOptionParser
Constructor Details
#initialize(args) ⇒ ReceiverOptionParser
Initialization and parsing of basic, common and specific receiver options
Parameters
- args
-
arguments to parse
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/options/receiver_option_parser.rb', line 39 def initialize(args) # Initialization of basic and common options super() # Receiver usage @opt_parser. = "Usage: <receiver_program> [OPTIONS]" # Receiver specific options with default values # Number of messages option @options.count = Defaults::DEFAULT_COUNT # Credit for messages to be pre-fetched @options.prefetch = Defaults::DEFAULT_PREFETCH # Process reply to @options.process_reply_to = Defaults::DEFAULT_PROC_REPLY_TO # Browse messages @options.browse = Defaults::DEFAULT_BROWSE # Filter using selector @options.selector = Defaults::DEFAULT_SELECTOR # Receiver listen @options.recv_listen = Defaults::DEFAULT_RECV_LISTEN # Receiver listen port @options.recv_listen_port = Defaults::DEFAULT_RECV_LISTEN_PORT # Number of messages @opt_parser.on( "-c", "--count COUNT", Integer, "number of messages to receiver "+ "(default: #{Defaults::DEFAULT_COUNT})" ) do |count| @options.count = count end # Prefetch @opt_parser.on( "--reactor-prefetch PREFETCH", Integer, "receiver's prefetch count "+ "(default: #{Defaults::DEFAULT_PREFETCH})" ) do |prefetch| @options.prefetch = prefetch end # Process reply to @opt_parser.on( "--process-reply-to", "send message to reply-to address if enable and message got reply-to "+ "address", ) do |process_reply_to| @options.process_reply_to = process_reply_to end # Browse messages @opt_parser.on( "--recv-browse", "browse messages instead of reading", ) do |browse| @options.browse = browse end # Filter messages @opt_parser.on( "--recv-selector SELECTOR", "filter messages using a selector" ) do |selector| @options.selector = selector end # Receiver listen @opt_parser.on( "--recv-listen LISTEN", Options::BOOLEAN_STRINGS, "enable receiver listen (P2P) (#{Options::BOOLEAN_STRINGS.join("/")}, "+ "default: #{Defaults::DEFAULT_RECV_LISTEN})" ) do |recv_listen| @options.recv_listen = StringUtils.str_to_bool(recv_listen) end # Receiver listen port @opt_parser.on( "--recv-listen-port PORT", Integer, "define port for local listening "+ "(range: #{Constants::CONST_MIN_PORT_RANGE_VALUE}-"+ "#{Constants::CONST_MAX_PORT_RANGE_VALUE}, "+ "default: #{Defaults::DEFAULT_RECV_LISTEN_PORT})" ) do |recv_listen_port| if recv_listen_port < Constants::CONST_MIN_PORT_RANGE_VALUE \ or recv_listen_port > Constants::CONST_MAX_PORT_RANGE_VALUE raise OptionParser::InvalidArgument, "#{recv_listen_port} "+ "(out of range: #{Constants::CONST_MIN_PORT_RANGE_VALUE}-"+ "#{Constants::CONST_MAX_PORT_RANGE_VALUE})" end @options.recv_listen_port = recv_listen_port end # Duration mode @options.duration_mode = "before-receive" duration_modes = %w(before-receive after-receive after-receive-action after-receive-tx-action) @opt_parser.on( "--duration-mode MODE", duration_modes, "in use with --duration defines where to wait (allowed: #{duration_modes.join(', ')}, default: #{@options.duration_mode})" ) do |d| @options.duration_mode = d end # Parse basic, common and specific options for receiver client parse(args) end |