bin/teamocil in teamocil-0.1.2 vs bin/teamocil in teamocil-0.1.3
- old
+ new
@@ -1,10 +1,34 @@
#!/usr/bin/env ruby
-require File.dirname(__FILE__)+"/../lib/teamocil"
+def bail(msg)
+ puts msg
+ exit(1)
+end
-if ENV["TMUX"] == nil
- puts "You must be in a tmux session to use teamocil"
-else
- layout = Teamocil::Layout.new(ARGV[0], File.join("#{ENV["HOME"]}/.teamocil", "#{ARGV[0]}.yml"))
- layout.to_tmux
+$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
+
+require 'yaml'
+require 'teamocil'
+require 'optparse'
+
+bail "You must be in a tmux session to use teamocil" unless ENV["TMUX"]
+
+options = {}
+opts = OptionParser.new do |opts|
+ opts.banner = "Usage: teamocil [options] <layout>
+
+Options:
+ "
+ opts.on("--here", "Set up the first window in the current window") do |safe|
+ options[:here] = true
+ end
+
end
+opts.parse!
+
+file = File.join("#{ENV["HOME"]}/.teamocil", "#{ARGV[0]}.yml")
+
+bail "There is no file \"#{file}\"" unless File.exists?(file)
+
+layout = Teamocil::Layout.new(file, options)
+layout.to_tmux