Class: InternetSampler::CLI
- Inherits:
-
Object
- Object
- InternetSampler::CLI
- Defined in:
- lib/internet-sampler/cli.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(args) ⇒ CLI
Returns a new instance of CLI.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/internet-sampler/cli.rb', line 7 def initialize args = { port: 9292, bind: 'localhost', environment: :development, } = { tracks: [] } opt = OptionParser.new opt.on('-p port', '--port port', 'port to listen (default is 9292)') { |i| [:port] = i.to_i } opt.on('-b host', '--bind host', 'host to bind (default is localhost)') { |i| [:bind] = i } opt.on('-e env', '--environment env', 'environment to run (production, test or development; default is development)') { |i| if %w{development test production}.include? i [:environment] = i.to_sym end } opt.on('-t slug:url', '--track slug:url', 'sample sound to serve (note that `url\' is not path to file but URL to serve)') { |i| if track = i.match(/^([^:]*):(.*)$/) [:tracks] << { slug: track[1], path: track[2] } end } opt.parse! args InternetSampler::Application. , end |