bin/patchmaster in patchmaster-0.0.0 vs bin/patchmaster in patchmaster-0.0.1
- old
+ new
@@ -1,20 +1,28 @@
#!/usr/bin/env ruby
#
-# usage: patchmaster [-i] [pm_file]
+# usage: patchmaster [-n] [-d] [pm_file]
#
# Starts PatchMaster and optionally loads pm_file.
#
# The -n flag tells PatchMaster to not use MIDI. All MIDI errors such as not
-# being able to connect to the MIDI devices speicified in pm_file are
+# being able to connect to the MIDI instruments specified in pm_file are
# ignored, and no MIDI data is sent/received. That is useful if you want to
-# run PatchMaster without actually talking to any MIDI devices.
+# run PatchMaster without actually talking to any MIDI instruments.
+require 'optparse'
+
+use_midi = true
+OptionParser.new do |opts|
+ opts.banner = "usage: patchmaster [options] [pm_file]"
+ opts.on("-d", "--debug", "Turn on debug mode") { $DEBUG = true }
+ opts.on("-n", "--no-midi", "Turn off MIDI processing") { use_midi = false }
+end.parse!(ARGV)
+
+# Must require patchmaster here, after handling options, because Singleton
+# initialze code checks $DEBUG.
require 'patchmaster'
-pm = PM::Main.instance
-if ARGV[0] == '-n'
- pm.no_midi!
- ARGV.shift
-end
-pm.load(ARGV[0]) if ARGV[0]
-pm.run
+app = PM::Main.instance
+app.no_midi! if !use_midi
+app.load(ARGV[0]) if ARGV[0]
+app.run