Sha256: da12a99b51100481ee2d03243ad205f634e5f4d4f2f347a891b419e3ef641865

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

#!/usr/bin/env ruby
#
#  Created on 2007-12-6.
#  Copyright (c) 2007. All rights reserved.

begin
  require 'rubygems'
rescue LoadError
  # no rubygems to load, so we fail silently
end

require 'optparse'
require 'flac2mp3'
require 'flac2mp3/version'

# NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.

OPTIONS = {}
MANDATORY_OPTIONS = %w[]

parser = OptionParser.new do |opts|
  opts.banner = <<BANNER
Usage: #{File.basename($0)} [filename]

Options are:
BANNER
  opts.separator ''
  opts.on('-v', '--version',
          "Show the #{File.basename($0)} version number and exit") { puts "flac2mp3 #{Flac2mp3::VERSION::STRING}"; exit }
  opts.on('-d', '--[no-]delete',
          "Delete the original file after conversion") { |delete|  OPTIONS[:delete] = delete }
  opts.on('-s', '--silent',
          "Don't show progress") { |silent|  OPTIONS[:silent] = silent }
  opts.on('-e', '--encoding=ENCODING', String,
          "Set lame encoding options", "Default: #{Flac2mp3.default_encoding}") { |encoding|  OPTIONS[:encoding] = encoding }
  opts.on('-h', '--help',
          'Show this help message.') { puts opts; exit }
  opts.parse!(ARGV)

  if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
    puts opts; exit
  end
end

# do stuff
filename = ARGV[0]

unless filename
  puts "Usage: #{File.basename($0)} [filename]"
  exit
end

Flac2mp3.convert(filename, OPTIONS)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flac2mp3-0.3.1 bin/flac2mp3
flac2mp3-0.3.0 bin/flac2mp3