bin/patchmaster in patchmaster-0.0.6 vs bin/patchmaster in patchmaster-1.0.0
- old
+ new
@@ -1,31 +1,67 @@
#!/usr/bin/env ruby
#
-# usage: patchmaster [-n] [-d] [pm_file]
+# usage: patchmaster [-n] [-i] [-w] [-p port] [-t] [-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 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 instruments.
+#
+# To run PatchMaster from within an IRB session use -i. See the
+# documentation for details on the commands that are available.
+#
+# To run PatchMaster using a Web browser GUI use -w and point your browser
+# at http://localhost:4567. To change the port, use -p.
+#
+# To run PatchMaster without a GUI use -t. All output will go to the
+# console. The app will run until interrupted. (If you do this, you might
+# want to create a trigger that calls `panic', because you won't be able to
+# use the computer keyboard to do that.)
+#
+# The =-d= flag turns on debug mode. The app becomes slightly more verbose
+# and logs everything to `/tmp/pm_debug.txt'.
+
require 'optparse'
use_midi = true
-use_gui = true
+gui = :curses
+port = nil
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 }
- opts.on("-t", "--text", "--nw", "--no-window", "No windows") { use_gui = false }
+ opts.on("-i", "--irb", "Use an IRB console") { gui = :irb }
+ opts.on("-w", "--web", "Use a Web browser GUI") { gui = :web }
+ opts.on("-p", "--port PORT", "Web browser GUI port number") { |opt| port = opt.to_i }
+ opts.on("-t", "--text", "--nw", "--no-window", "No windows") { gui = :text }
+ opts.on_tail("-h", "-?", "--help", "Show this message") do
+ puts opts
+ exit 0
+ end
end.parse!(ARGV)
# Must require patchmaster here, after handling options, because Singleton
# initialize code checks $DEBUG.
require 'patchmaster'
-app = use_gui ? PM::Main.instance : PM::PatchMaster.instance
-app.no_gui! if !use_gui
-app.no_midi! if !use_midi
-app.load(ARGV[0]) if ARGV[0]
-app.run
+pm = PM::PatchMaster.instance
+pm.use_midi = use_midi
+pm.load(ARGV[0]) if ARGV[0]
+case gui
+when :curses
+ require 'patchmaster/curses/main'
+ pm.gui = PM::Main.instance
+ pm.run
+when :irb
+ require 'patchmaster/irb'
+ start_patchmaster_irb
+when :web
+ require 'patchmaster/web/sinatra_app'
+ app = PM::SinatraApp.instance
+ app.port = port if port
+ pm.gui = app
+ pm.run
+end