Class: GfmLivePreview::CLI
- Inherits:
-
Object
- Object
- GfmLivePreview::CLI
- Defined in:
- lib/gfm_live_preview/cli.rb
Constant Summary collapse
- DEFAULTS =
{ port: 31337, }
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ CLI
constructor
A new instance of CLI.
- #parse ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLI
Returns a new instance of CLI.
11 12 13 |
# File 'lib/gfm_live_preview/cli.rb', line 11 def initialize(argv) @argv = argv end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
9 10 11 |
# File 'lib/gfm_live_preview/cli.rb', line 9 def argv @argv end |
Class Method Details
.parse(argv) ⇒ Object
15 16 17 |
# File 'lib/gfm_live_preview/cli.rb', line 15 def self.parse(argv) new(argv).parse end |
Instance Method Details
#parse ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gfm_live_preview/cli.rb', line 19 def parse = DEFAULTS.dup OptionParser.new do |opts| opts. = "Usage: #{File.basename($PROGRAM_NAME)} [options] FILE" opts.on '-p', '--port PORT', 'Specify port other than 31337' do |port| [:port] = port.to_i end end.parse(argv) file = argv.last if file.nil? @argv = ['-h'] parse end [file, ] end |