Class: At_email::Config::Cmd_Opt_Parser
- Inherits:
-
Object
- Object
- At_email::Config::Cmd_Opt_Parser
- Defined in:
- lib/at_email/config/cmd_opt_parser.rb
Constant Summary collapse
- CODES =
%w[iso-2022-jp shift_jis euc-jp utf8 binary]
- CODE_ALIASES =
{ "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#quiet ⇒ Object
readonly
Returns the value of attribute quiet.
-
#silent ⇒ Object
readonly
Returns the value of attribute silent.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(args) ⇒ Cmd_Opt_Parser
constructor
A new instance of Cmd_Opt_Parser.
Constructor Details
#initialize(args) ⇒ Cmd_Opt_Parser
Returns a new instance of Cmd_Opt_Parser.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/at_email/config/cmd_opt_parser.rb', line 17 def initialize(args) @silent = false @quiet = false @verbose = false opt_parser = OptionParser.new do |opts| opts. = "Usage: #{$PROGRAM_NAME} [options]" opts.separator "" opts.separator "Options:" opts.on("-c [CONFIG FILE]", "--config-file [CONFIG FILE]", String, "Config File (JSON)") do |config_file| @config_file = config_file end opts.on("-s", "--silent", "Run silently") do @silent = true end opts.on("-q", "--quiet", "Run quietly") do @quiet = true if @silent @silent = false end end opts.on("-v", "--verbose", "Run verbosely") do @verbose = true if @quiet @quiet = false end if @silent @silent = false end end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do puts At_email::VERSION exit end end opt_parser.parse!(args) end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
9 10 11 |
# File 'lib/at_email/config/cmd_opt_parser.rb', line 9 def config_file @config_file end |
#quiet ⇒ Object (readonly)
Returns the value of attribute quiet.
11 12 13 |
# File 'lib/at_email/config/cmd_opt_parser.rb', line 11 def quiet @quiet end |
#silent ⇒ Object (readonly)
Returns the value of attribute silent.
12 13 14 |
# File 'lib/at_email/config/cmd_opt_parser.rb', line 12 def silent @silent end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
10 11 12 |
# File 'lib/at_email/config/cmd_opt_parser.rb', line 10 def verbose @verbose end |