ensure layout editing is allowed outside of tmux sessions
This commit is contained in:
parent
9ad83268ee
commit
bb85ff7641
@ -12,8 +12,6 @@ module Teamocil
|
|||||||
# @param argv [Hash] the command line parameters hash (usually `ARGV`).
|
# @param argv [Hash] the command line parameters hash (usually `ARGV`).
|
||||||
# @param env [Hash] the environment variables hash (usually `ENV`).
|
# @param env [Hash] the environment variables hash (usually `ENV`).
|
||||||
def initialize(argv, env) # {{{
|
def initialize(argv, env) # {{{
|
||||||
bail "You must be in a tmux session to use teamocil" unless env["TMUX"]
|
|
||||||
|
|
||||||
parse_options! argv
|
parse_options! argv
|
||||||
layout_path = File.join("#{env["HOME"]}", ".teamocil")
|
layout_path = File.join("#{env["HOME"]}", ".teamocil")
|
||||||
|
|
||||||
@ -30,9 +28,12 @@ module Teamocil
|
|||||||
|
|
||||||
if @options[:edit]
|
if @options[:edit]
|
||||||
::FileUtils.touch file unless File.exists?(file)
|
::FileUtils.touch file unless File.exists?(file)
|
||||||
system("$EDITOR \"#{file}\"")
|
|
||||||
|
Kernel.system("$EDITOR \"#{file}\"")
|
||||||
else
|
else
|
||||||
bail "There is no file \"#{file}\"" unless File.exists?(file)
|
bail "There is no file \"#{file}\"" unless File.exists?(file)
|
||||||
|
bail "You must be in a tmux session to use teamocil" unless env["TMUX"]
|
||||||
|
|
||||||
parsed_layout = YAML.load_file(file)
|
parsed_layout = YAML.load_file(file)
|
||||||
@layout = Teamocil::Layout.new(parsed_layout, @options)
|
@layout = Teamocil::Layout.new(parsed_layout, @options)
|
||||||
@layout.compile!
|
@layout.compile!
|
||||||
|
@ -4,6 +4,22 @@ describe Teamocil::CLI do
|
|||||||
|
|
||||||
context "executing" do
|
context "executing" do
|
||||||
|
|
||||||
|
context "not in tmux" do
|
||||||
|
|
||||||
|
before do # {{{
|
||||||
|
@fake_env = { "TMUX" => 1, "HOME" => File.join(File.dirname(__FILE__), "fixtures") }
|
||||||
|
end # }}}
|
||||||
|
|
||||||
|
it "should allow editing" do # {{{
|
||||||
|
FileUtils.stub(:touch)
|
||||||
|
Kernel.should_receive(:system).with(any_args())
|
||||||
|
|
||||||
|
@cli = Teamocil::CLI.new(["--edit", "my-layout"], @fake_env)
|
||||||
|
end # }}}
|
||||||
|
end
|
||||||
|
|
||||||
|
context "in tmux" do
|
||||||
|
|
||||||
before do # {{{
|
before do # {{{
|
||||||
@fake_env = { "TMUX" => 1, "HOME" => File.join(File.dirname(__FILE__), "fixtures") }
|
@fake_env = { "TMUX" => 1, "HOME" => File.join(File.dirname(__FILE__), "fixtures") }
|
||||||
end # }}}
|
end # }}}
|
||||||
@ -24,3 +40,4 @@ describe Teamocil::CLI do
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
@ -25,5 +25,4 @@ spec = Gem::Specification.new do |s|
|
|||||||
s.add_development_dependency "rspec"
|
s.add_development_dependency "rspec"
|
||||||
s.add_development_dependency "yard"
|
s.add_development_dependency "yard"
|
||||||
s.add_development_dependency "maruku"
|
s.add_development_dependency "maruku"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user