def initialize(argv, env)
bail "You must be in a tmux session to use teamocil" unless env["TMUX"]
parse_options! argv
layout_path = File.join("#{env["HOME"]}", ".teamocil")
if @options.include?(:list)
@layouts = get_layouts(layout_path)
return print_layouts
end
if @options.include?(:layout)
file = @options[:layout]
else
file = ::File.join(layout_path, "#{argv[0]}.yml")
end
if @options[:edit]
::FileUtils.touch file unless File.exists?(file)
system("$EDITOR \"#{file}\"")
else
bail "There is no file \"#{file}\"" unless File.exists?(file)
parsed_layout = YAML.load_file(file)
@layout = Teamocil::Layout.new(parsed_layout, @options)
@layout.compile!
@layout.execute_commands(@layout.generate_commands)
end
end