threeman 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c27245f62909c634dffc2b58459d0274a43b7bd5
4
- data.tar.gz: 171dfafb1e03b7511e7b77bafdf244cc46eb2117
3
+ metadata.gz: 69d8685bd916a582798ff25ff645c0cc0d1b2349
4
+ data.tar.gz: 09caa15bd71c1c46aae565d13ae450ee1c064019
5
5
  SHA512:
6
- metadata.gz: 508af4ea8207a1bd4411944b89d75799552d4841209a69f188b129eb6eacfe940fdd87f8737d2344180a32d9badc7345f61ff71eddcfb9207d76b160d29a3cdc
7
- data.tar.gz: 7ff53715ab635ebf6ada6f68ac9f2d43e2e00b7903cf32b62a6347ebdbffed6f5ac5bab2f48c8b0198cff89f7b86e8e67dd8541ab62af785c0433abce888eed9
6
+ metadata.gz: bdd20f5247ee87ec37f52cf27169c6f6b409940410e9238f92c88e9ee758476dfb0c34ac6c66fdd7dba6f47021a46776fcd1341e71cb213bbdcabfb28ff60527
7
+ data.tar.gz: ad118a7c53bb3b6aacf54e6285708dc2af36216e34e1fe895dbdf940e761ff5918a79c2700ee37e2e54c7afca54fba4629d2fefb3483061cbb4ae2049bf586e1
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /tmux-client-*.log
11
+ /.ruby-version
data/.threeman ADDED
@@ -0,0 +1,3 @@
1
+ panes:
2
+ - one
3
+ - three
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.5.0 - May 31, 2017
2
+
3
+ * Adds `--panes=command_name command_two` to run certain commands in panes
4
+
1
5
  # 0.4.0 - March 18, 2017
2
6
 
3
7
  * Support reading .threeman or .foreman files to get the default options
@@ -28,4 +32,4 @@
28
32
 
29
33
  # 0.1.0 - March 28, 2016
30
34
 
31
- * First release
35
+ * First release
data/Procfile ADDED
@@ -0,0 +1,3 @@
1
+ one: echo 1; sleep 10
2
+ two: echo 2; sleep 10
3
+ three: echo 3; sleep 10
data/lib/threeman/cli.rb CHANGED
@@ -4,17 +4,17 @@ require 'yaml'
4
4
 
5
5
  module Threeman
6
6
  FRONTENDS = {
7
- :iterm3 => lambda {
7
+ :iterm3 => lambda { |options|
8
8
  require 'threeman/frontends/iterm3'
9
- Threeman::Frontends::Iterm3.new
9
+ Threeman::Frontends::Iterm3.new(options)
10
10
  },
11
- :mac_terminal => lambda {
11
+ :mac_terminal => lambda { |options|
12
12
  require 'threeman/frontends/mac_terminal'
13
- Threeman::Frontends::MacTerminal.new
13
+ Threeman::Frontends::MacTerminal.new(options)
14
14
  },
15
- :tmux => lambda {
15
+ :tmux => lambda { |options|
16
16
  require 'threeman/frontends/tmux'
17
- Threeman::Frontends::Tmux.new
17
+ Threeman::Frontends::Tmux.new(options)
18
18
  }
19
19
  }
20
20
 
@@ -23,7 +23,10 @@ module Threeman
23
23
 
24
24
  desc "start", "Start the application"
25
25
  option :frontend, desc: "Which frontend to use. One of: #{FRONTENDS.keys.sort.join(', ')}"
26
+ option :panes, desc: "Runs each command in a pane, if supported by the frontend. (Currently supported in iterm3 and tmux.)", type: :array
26
27
  option :port, desc: "The port to run the application on. This will set the PORT environment variable.", type: :numeric
28
+ option :layout_name, desc: "If using tmux, the layout name to use for paned commands", type: :string
29
+
27
30
  def start
28
31
  pwd = Dir.pwd
29
32
  procfile = Threeman::Procfile.new(File.expand_path("Procfile", pwd))
@@ -36,11 +39,11 @@ module Threeman
36
39
  exit! 1
37
40
  end
38
41
 
39
- frontend(frontend_name).run_commands(commands)
42
+ frontend(frontend_name, options).run_commands(commands)
40
43
  end
41
44
 
42
45
  private
43
- def frontend(name)
46
+ def frontend(name, options = {})
44
47
  frontend_lambda = FRONTENDS[name.to_sym]
45
48
  unless frontend_lambda
46
49
  puts "No frontend named #{name}!"
@@ -48,7 +51,7 @@ module Threeman
48
51
  exit! 1
49
52
  end
50
53
 
51
- frontend_lambda.call
54
+ frontend_lambda.call(options)
52
55
  end
53
56
 
54
57
  def auto_frontend
@@ -83,4 +86,4 @@ module Threeman
83
86
  @dotfile ||= ['.threeman', '.foreman'].find { |filename| File.file?(filename) }
84
87
  end
85
88
  end
86
- end
89
+ end
@@ -2,6 +2,12 @@ require 'shellwords'
2
2
 
3
3
  module Threeman
4
4
  class Frontend
5
+ attr_reader :options
6
+
7
+ def initialize(options)
8
+ @options = options
9
+ end
10
+
5
11
  def run_commands(commands)
6
12
  raise "Subclasses must implement #run_commands"
7
13
  end
@@ -12,5 +18,13 @@ module Threeman
12
18
  command.bash_script
13
19
  ].join(" ; ")
14
20
  end
21
+
22
+ def sort_commands(commands)
23
+ commands.sort_by { |c| paned_command_names.include?(c.name) ? 0 : 1 }
24
+ end
25
+
26
+ def paned_command_names
27
+ options[:panes] || []
28
+ end
15
29
  end
16
- end
30
+ end
@@ -14,9 +14,13 @@ module Threeman
14
14
  iterm.activate
15
15
  window = iterm.create_window_with_default_profile
16
16
 
17
- commands.each_with_index do |command, index|
17
+ sort_commands(commands).each_with_index do |command, index|
18
18
  current_tab = if index == 0
19
19
  window
20
+ elsif paned_command_names.include?(command.name)
21
+ tab = window.current_session.split_horizontally_with_same_profile
22
+ tab.select
23
+ window
20
24
  else
21
25
  window.create_tab_with_default_profile
22
26
  end
@@ -33,4 +37,4 @@ module Threeman
33
37
  end
34
38
  end
35
39
  end
36
- end
40
+ end
@@ -39,4 +39,4 @@ module Threeman
39
39
  end
40
40
  end
41
41
  end
42
- end
42
+ end
@@ -5,12 +5,13 @@ module Threeman
5
5
  class Tmux < Threeman::Frontend
6
6
  attr_reader :session
7
7
 
8
- def initialize
8
+ def initialize(options)
9
9
  @session = "threeman_#{Time.now.to_i}"
10
+ super
10
11
  end
11
12
 
12
13
  def run_commands(commands)
13
- commands.each_with_index do |command, index|
14
+ sort_commands(commands).each_with_index do |command, index|
14
15
  run_command(command, index)
15
16
  end
16
17
 
@@ -21,13 +22,21 @@ module Threeman
21
22
  def run_command(command, index)
22
23
  bash_cmd = "bash -c #{Shellwords.escape bash_script(command)}"
23
24
 
24
- common_opts = "-n #{Shellwords.escape command.name} -c #{Shellwords.escape command.workdir} #{Shellwords.escape bash_cmd}"
25
+ name_opt = "-n #{Shellwords.escape command.name}"
26
+ common_opts = "-c #{Shellwords.escape command.workdir} #{Shellwords.escape bash_cmd}"
25
27
  if index == 0
26
- system "tmux new-session -d -s #{session} #{common_opts}"
28
+ system "tmux new-session -d -s #{session} #{name_opt} #{common_opts}"
29
+ elsif paned_command_names.include?(command.name)
30
+ system "tmux split-window -v -d -f -t #{session}:0.#{index - 1} #{common_opts}"
31
+ system "tmux select-layout -t #{session}:0 #{layout_name}"
27
32
  else
28
- system "tmux -v new-window -t #{session}:#{index} #{common_opts}"
33
+ system "tmux -v new-window -t #{session}:#{index} #{name_opt} #{common_opts}"
29
34
  end
30
35
  end
36
+
37
+ def layout_name
38
+ options[:layout_name] || 'tiled'
39
+ end
31
40
  end
32
41
  end
33
- end
42
+ end
@@ -13,4 +13,4 @@ module Threeman
13
13
  commands
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Threeman
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: threeman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nat Budin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-18 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman
@@ -104,11 +104,13 @@ extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
106
  - ".gitignore"
107
+ - ".threeman"
107
108
  - ".travis.yml"
108
109
  - CHANGELOG.md
109
110
  - CODE_OF_CONDUCT.md
110
111
  - Gemfile
111
112
  - LICENSE
113
+ - Procfile
112
114
  - README.md
113
115
  - Rakefile
114
116
  - bin/console