sesh 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a613d7067baa2fea1feaa59c2aeb0f50ef62c78
4
- data.tar.gz: a4b76a0a66a7a9c18806240cf0c0dee791391d23
3
+ metadata.gz: e2379d1360354f9a664392fa0563f7f8c29e3cd3
4
+ data.tar.gz: 0e3f996071b819445f1c8f25681087cfc30cebf0
5
5
  SHA512:
6
- metadata.gz: e12d86c3a8fe8e8c6b81968f2ee47788627d28e9b2702e3c2ebb70192e8e03923bc921ae25c3e7d7812791bae309b830e2eeda3621620d8d6fe55d60af8d5e1f
7
- data.tar.gz: 7c914966416ad8e4891f4628b3f0765edb7d17a95b122048c7c07aacafe48dc77fd9a62acad47fa7a6dc23994bedcc84cfcd048ef144275a5dba8f6f4666e7d1
6
+ metadata.gz: 14cee1076c7d257fc6eb7efbd940071f1201720b485f12b719f820a54181dcb0c3c7871198c68ed266803c9d989c5a6573e40be9284c08eaed5777e73161cd3a
7
+ data.tar.gz: 11aff5ce1e417617c4dd6d691e5a30e1a50c451d9c75418eb1d495c831ee696c26bcb911c0769f2218ea51efcfbbc5b3db0908f26737a9ff19e1139b8675445f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sesh (0.1.0)
4
+ sesh (0.1.1)
5
5
  awesome_print
6
6
  colorize
7
7
  deep_merge
data/lib/sesh/cli.rb CHANGED
@@ -9,7 +9,7 @@ require 'deep_merge'
9
9
  module Sesh
10
10
  class Cli
11
11
  def self.start
12
- puts "Sesh v#{Sesh::VERSION}".green
12
+ puts; puts " Sesh v#{VERSION}".green; puts ' ==========='.green; puts
13
13
  if ARGV.empty? or ARGV.include? '-h' or ARGV.include? '--help'
14
14
  puts HELP_BANNER.blue; exit end
15
15
 
@@ -23,7 +23,7 @@ module Sesh
23
23
  if @tmux_control.already_running?
24
24
  Logger.fatal "Sesh project '#{@options[:project]}' is already running!"
25
25
  else
26
- Logger.debug "Starting Sesh project '#{@options[:project]}'..."
26
+ Logger.info "Starting Sesh project '#{@options[:project]}'..."
27
27
  end
28
28
  @tmux_control.kill_running_processes
29
29
  if @tmux_control.issue_start_command! &&
@@ -31,20 +31,20 @@ module Sesh
31
31
  sleep 1
32
32
  if @tmux_control.already_running?
33
33
  @tmux_control.store_pids_from_session!
34
- Logger.debug 'Sesh started successfully.'
34
+ Logger.success 'Sesh started successfully.'
35
35
  puts
36
36
  else Logger.fatal 'Sesh failed to start!' end
37
37
  else Logger.fatal 'Sesh failed to start after ten seconds!' end
38
38
  when 'stop'
39
39
  if @tmux_control.already_running?
40
- Logger.debug "Stopping Sesh project '#{@options[:project]}'..."
40
+ Logger.info "Stopping Sesh project '#{@options[:project]}'..."
41
41
  else
42
42
  Logger.fatal "Sesh project '#{@options[:project]}' is not running!"
43
43
  end
44
44
  @tmux_control.kill_running_processes
45
45
  @tmux_control.issue_stop_command!
46
46
  if $? && Logger.show_progress_until(-> { !@tmux_control.already_running? })
47
- Logger.debug 'Sesh stopped successfully.'
47
+ Logger.success 'Sesh stopped successfully.'
48
48
  puts
49
49
  else
50
50
  Logger.fatal 'Sesh failed to stop after ten seconds!'
@@ -83,8 +83,8 @@ module Sesh
83
83
  running_projects = output.split("\n")
84
84
  pcount = running_projects.count
85
85
  if pcount > 0
86
- Logger.info "#{pcount} project#{pcount>1 ? 's':''} currently running:"
87
- puts running_projects
86
+ Logger.success "#{pcount} project#{pcount>1 ? 's':''} currently running:"
87
+ running_projects.each {|rp| Logger.info rp, 1 }
88
88
  puts
89
89
  else
90
90
  Logger.fatal "There are no Sesh projects currently running."
@@ -99,13 +99,13 @@ module Sesh
99
99
  when 'enslave'
100
100
  Logger.fatal("Sesh project '#{@options[:project]}' is not running!") unless @tmux_control.already_running?
101
101
  Logger.fatal("You must specify a machine to enslave! Eg: user@ip") if @options[:ssh][:remote_addr].nil?
102
- Logger.debug "Attempting to connect #{@options[:ssh][:remote_addr]} to Sesh project '#{@options[:project]}'..."
102
+ Logger.info "Attempting to connect #{@options[:ssh][:remote_addr]} to Sesh project '#{@options[:project]}'..."
103
103
  if @ssh_control.enslave_peer!
104
- Logger.debug "Sesh client connected successfully."
105
- puts
104
+ Logger.success "Sesh client connected successfully."
106
105
  else
107
106
  Logger.fatal 'Sesh client failed to start.'
108
107
  end
108
+ when 'begin' then @tmux_control.begin_tmuxinator_session!
109
109
  when 'run'
110
110
  unless ARGV.any?
111
111
  Logger.fatal 'A second command is required!'
data/lib/sesh/logger.rb CHANGED
@@ -4,8 +4,8 @@ require 'colorize'
4
4
  module Sesh
5
5
  class Logger
6
6
  def self.debug(msg) $stderr.puts "> #{msg}" end
7
- def self.fatal(msg)
8
- $stderr.puts msg.red; $stderr.puts; exit 1 end
7
+ def self.fatal(msg, nest_level=0)
8
+ $stderr.puts "#{' ' * nest_level * 2}> #{msg}".red; $stderr.puts; exit 1 end
9
9
  def self.warn(msg, nest_level=0)
10
10
  $stderr.puts "#{' ' * nest_level * 2}> #{msg}".yellow end
11
11
  def self.info(msg, nest_level=0)
@@ -36,10 +36,9 @@ module Sesh
36
36
  end
37
37
 
38
38
  def enslave_peer!
39
- output = Sesh.format_and_run_command <<-BASH
40
- ssh #{@options[:remote_addr]} "sesh connect #{@project} #{@options[:local_addr]}"
39
+ puts Sesh.format_and_run_command <<-BASH
40
+ ssh #{@options[:remote_addr]} -t "sesh connect #{@project} #{@options[:local_addr]}"
41
41
  BASH
42
- puts output
43
42
  $?
44
43
  end
45
44
  end
@@ -16,10 +16,11 @@ module Sesh
16
16
 
17
17
  def issue_start_command!
18
18
  cmd = Sesh.format_command <<-BASH
19
- tmux -S "#{@options[:socket_file]}" new-session -d "eval \$SHELL -l; env TMUX='' mux start #{@project}" 2>&1
19
+ tmux -S "#{@options[:socket_file]}" new-session -d "eval \\"\$SHELL -l -c 'rvm use default; bundle exec sesh begin'\\"" 2>&1
20
20
  BASH
21
+ # puts cmd
21
22
  output = `#{cmd}`.strip
22
- return true if output.length == 0
23
+ return true if $? && output.length == 0
23
24
  Logger.warn "Tmux failed to start with the following error: #{output}"; false
24
25
  end
25
26
 
@@ -29,7 +30,8 @@ module Sesh
29
30
 
30
31
  def obtain_pids_from_session
31
32
  # TODO: grep this to just those pids from the current project
32
- `tmux list-panes -s -F "\#{pane_pid} \#{pane_current_command}" | grep -v tmux | awk '{print $1}'`.strip.lines end
33
+ `tmux -S "#{@options[:socket_file]}" list-panes -s -F "\#{pane_pid} \#{pane_current_command}" | grep -v tmux | awk '{print $1}'`.strip.lines
34
+ end
33
35
  def store_pids_from_session!
34
36
  File.open(@options[:pids_file], 'w') {|f|
35
37
  obtain_pids_from_session.each{|pid| f.puts pid } }
@@ -43,6 +45,9 @@ module Sesh
43
45
  end
44
46
  def kill_process!(pid); `kill -9 #{pid}` end
45
47
 
48
+ def begin_tmuxinator_session!
49
+ %x[env TMUX='' mux start #{@project}] end
50
+
46
51
  # Getter methods for passthru to SshControl class
47
52
  def project; @project end
48
53
  def options; @options end
data/lib/sesh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sesh
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sesh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MacKinley Smith