Class: Teamocil::CLI
- Inherits:
-
Object
- Object
- Teamocil::CLI
- Defined in:
- lib/teamocil/cli.rb
Overview
This class handles interaction with the tmux
utility.
Instance Method Summary (collapse)
-
- (Object) bail(msg)
Print an error message and exit the utility.
-
- (CLI) initialize(argv, env)
constructor
Initialize a new run of
tmux
. -
- (Object) parse_options!
Parse the command line options.
Constructor Details
- (CLI) initialize(argv, env)
Initialize a new run of tmux
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/teamocil/cli.rb', line 12 def initialize(argv, env) # {{{ bail "You must be in a tmux session to use teamocil" unless env["TMUX"] if .include?(:layout) file = [:layout] else file = ::File.join("#{env["HOME"]}/.teamocil", "#{argv[0]}.yml") end if [:edit] ::FileUtils.touch file unless File.exists?(file) system("$EDITOR \"#{file}\"") else bail "There is no file \"#{file}\"" unless File.exists?(file) layout = Teamocil::Layout.new(file, ) layout.to_tmux end end |
Instance Method Details
- (Object) bail(msg)
Print an error message and exit the utility
59 60 61 62 |
# File 'lib/teamocil/cli.rb', line 59 def bail(msg) # {{{ puts "[teamocil] #{msg}" exit 1 end |
- (Object) parse_options!
Parse the command line options
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/teamocil/cli.rb', line 33 def = {} opts = ::OptionParser.new do |opts| opts. = "Usage: teamocil [options] <layout> Options: " opts.on("--here", "Set up the first window in the current window") do [:here] = true end opts.on("--edit", "Edit the YAML layout file instead of using it") do [:edit] = true end opts.on("--layout [LAYOUT]", "Use a specific layout file, instead of ~/.teamocil/<layout>.yml") do |layout| [:layout] = layout end end opts.parse! end |