Class: Bake::BakeFormatOptions
- Defined in:
- lib/format/options/options.rb
Instance Attribute Summary collapse
-
#end_line ⇒ Object
readonly
Fixnum.
-
#indent ⇒ Object
readonly
String.
-
#input ⇒ Object
readonly
String.
-
#output ⇒ Object
readonly
String.
-
#start_line ⇒ Object
readonly
Fixnum.
Instance Method Summary collapse
-
#initialize(argv) ⇒ BakeFormatOptions
constructor
A new instance of BakeFormatOptions.
- #parse_options ⇒ Object
- #usage ⇒ Object
Methods inherited from Parser
#add_option, #get_block, #num_parameter?, #parse_internal, #valid?
Constructor Details
#initialize(argv) ⇒ BakeFormatOptions
Returns a new instance of BakeFormatOptions.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/format/options/options.rb', line 10 def initialize(argv) super(argv) @input = '-' @output = '-' @start_line = nil @end_line = nil @indent = ' ' @index = 0 add_option(["" ], lambda { |x| collect_args(x) }) add_option(["--indent" ], lambda { |x| @indent = x }) add_option(["--lines" ], lambda { |x| set_lines(x) }) add_option(["-h", "--help" ], lambda { usage; ExitHelper.exit(0) }) add_option(["--version" ], lambda { Bake::Version.printBakeFormatVersion; ExitHelper.exit(0) }) end |
Instance Attribute Details
#end_line ⇒ Object (readonly)
Fixnum
8 9 10 |
# File 'lib/format/options/options.rb', line 8 def end_line @end_line end |
#indent ⇒ Object (readonly)
String
7 8 9 |
# File 'lib/format/options/options.rb', line 7 def indent @indent end |
#input ⇒ Object (readonly)
String
7 8 9 |
# File 'lib/format/options/options.rb', line 7 def input @input end |
#output ⇒ Object (readonly)
String
7 8 9 |
# File 'lib/format/options/options.rb', line 7 def output @output end |
#start_line ⇒ Object (readonly)
Fixnum
8 9 10 |
# File 'lib/format/options/options.rb', line 8 def start_line @start_line end |
Instance Method Details
#parse_options ⇒ Object
38 39 40 |
# File 'lib/format/options/options.rb', line 38 def () parse_internal(true) end |
#usage ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/format/options/options.rb', line 27 def usage puts [ "Usage: #{__FILE__} [--indent=string] [--lines=string] input output", " --indent=string, indent defaults to two spaces.", " Note, you can escape a tab in bash by ctrl-vTAB with sourrounding \" e.g. \"--input= \"", " --lines=string, [start line]:[end line] - format a range of lines.", " input, filename or '-' for stdin", " output, filename, '-' for stdout, '--' for same as input file" ].join("\n") end |