Class: ArgsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ffsplitter/args_parser.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  audio_only: false
}

Class Method Summary collapse

Class Method Details

.parse!(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ffsplitter/args_parser.rb', line 9

def self.parse!(args)
  options = OpenStruct.new(DEFAULT_OPTIONS)
  options.filename = args[0]

  parser = OptionParser.new do |opts|
    opts.banner = "Usage: ffsplitter test.mp4 [options]"

    opts.on("-e", "--output-extension EXTENSION", "Output extension") do |ext|
      options.output_extension = ext
    end

    opts.on("-o", "--output-path PATH", "Output path") do |dir|
      options.output_path = File.expand_path(dir)
    end
  end

  parser.parse!(args)
  options
end