Class: StackOperations::OptionParserWrapper
- Inherits:
-
Object
- Object
- StackOperations::OptionParserWrapper
- Defined in:
- lib/mk_stack/mk_stack.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(argv) ⇒ OptionParserWrapper
constructor
A new instance of OptionParserWrapper.
Constructor Details
#initialize(argv) ⇒ OptionParserWrapper
Returns a new instance of OptionParserWrapper.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mk_stack/mk_stack.rb', line 12 def initialize(argv) @options = { flatten: false, nest: false, dryrun: true, reverse: false, empty: false, no_dir_move: false } @args = [] begin OptionParser.new do |opts| opts. = "Usage: hc stack [options]" opts.on('-o ORDINAL', '--ordinal=ORDINAL', 'Add ordinal number') { |ord| @options[:ordinal] = ord } opts.on('-d', '--dryrun', 'Dry run (do not move or create anything)') { @options[:dryrun] = true } opts.on('-D', 'Do not move directories (only move files)') { @options[:no_dir_move] = true } opts.on('-A', 'Do not move hidden files and directories') { @options[:no_hidden] = true } opts.on('-c', '--create', 'Create (empty) stack only') { @options[:empty] = true } opts.on('-e', '--exec', 'Execute stack making') { @options[:dryrun] = false } opts.on('-f', '--flatten', 'Flatten stacks') { @options[:flatten] = true } opts.on('-n', '--nest', 'Nest stacks by _yymmdd') { @options[:nest] = true } opts.on('-r', '--reverse', 'Reverse _yymmdd order for nest') { @options[:reverse] = true } end.parse!(argv) rescue OptionParser::InvalidOption => e puts "Error: #{e.}" exit 1 end @args = argv end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/mk_stack/mk_stack.rb', line 10 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/mk_stack/mk_stack.rb', line 10 def @options end |