bin/patchmaster in patchmaster-1.0.0 vs bin/patchmaster in patchmaster-1.1.2

- old
+ new

@@ -1,31 +1,28 @@ #!/usr/bin/env ruby # -# usage: patchmaster [-n] [-i] [-w] [-p port] [-t] [-d] [pm_file] +# usage: patchmaster [-v] [-n] [-i] [-w] [-p port] [-d] [pm_file] # # Starts PatchMaster and optionally loads pm_file. # +# -v outputs the version number and exits. +# # 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 +# To run PatchMaster from within an IRB session use -i. Reads +# ./.patchmasterrc if it exists, $HOME/.patchmasterrc if not. 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'. +# 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 gui = :curses port = nil @@ -34,11 +31,16 @@ opts.on("-d", "--debug", "Turn on debug mode") { $DEBUG = true } opts.on("-n", "--no-midi", "Turn off MIDI processing") { use_midi = 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("-v", "--version", "Show version number and exit") do + version_line = IO.readlines(File.join(File.dirname(__FILE__), '../Rakefile')).grep(/GEM_VERSION\s*=/).first + version_line =~ /(\d+\.\d+\.\d+)/ + puts "patchmaster #{$1}" + exit 0 + end opts.on_tail("-h", "-?", "--help", "Show this message") do puts opts exit 0 end end.parse!(ARGV) @@ -54,11 +56,11 @@ when :curses require 'patchmaster/curses/main' pm.gui = PM::Main.instance pm.run when :irb - require 'patchmaster/irb' - start_patchmaster_irb + require 'patchmaster/irb/irb' + start_patchmaster_irb(File.join(File.dirname(__FILE__), 'irb_init.rb')) when :web require 'patchmaster/web/sinatra_app' app = PM::SinatraApp.instance app.port = port if port pm.gui = app