automux 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -182,6 +182,8 @@ windows:
182
182
 
183
183
  `automux test` will use the current directory.
184
184
 
185
+ `automux test -h` will list the valid options.
186
+
185
187
  #### Note
186
188
 
187
189
  * Since the opts are derived from the blueprint, the blueprint name needs to precede the opts as seen in the above commands.
@@ -253,10 +255,10 @@ This will execute the following steps
253
255
  * ... tmux startup stuff
254
256
  * ... create first window
255
257
  * cd automux
256
- * pwd => ~/projects/automux
258
+ * pwd #=> ~/projects/automux
257
259
  * vim
258
260
  * ... create second window
259
- * pwd => ~/projects
261
+ * pwd #=> ~/projects
260
262
 
261
263
  The session/window hooks have access to session and window objects respectively.
262
264
 
@@ -314,12 +316,12 @@ cd <%= root %>
314
316
  = attach_session
315
317
  ```
316
318
 
317
- Its a simpler form of ERB much like [HAML](https://github.com/haml/haml) without indentation. The ERB is evaluated with session's context. Hence all methods defined for session are available here. Custom recipes can be run like so:
319
+ Its a simpler form of ERB, much like [HAML](https://github.com/haml/haml) without indentation sensitivity. The ERB is evaluated with session's context. Hence all methods defined for session are available here. Custom recipes can be run like so:
318
320
 
319
321
  ```sh
320
322
  $ automux default custom_recipe
321
323
  ```
322
- _Here default is the default blueprint name._
324
+ _Where default is the **default** blueprint name._
323
325
 
324
326
  * Note: The default recipe comes from the Gem and cannot be overwritten. Running `automux default default` will invoke the recipe defined in the Gem instead of any user defined default. The primary reason for this approach is not the burden end users with the necessity to update their default recipe in future releases.
325
327
 
@@ -12,7 +12,7 @@ cd <%= root %>
12
12
  - end
13
13
 
14
14
  - windows.each do |window|
15
- = new_window(window)
15
+ = move_first_window_or_create_new(window)
16
16
  = rename_window(window) if window.name
17
17
 
18
18
  - if window.has_panes?
@@ -56,7 +56,7 @@ Feature: User using a custom recipe
56
56
  tmux start-server
57
57
  tmux new-session -d -s test
58
58
 
59
- tmux new-window -t test:2 2> /dev/null
59
+ tmux new-window -t test:2
60
60
  tmux send-keys -t test:2 "vim" C-m
61
61
 
62
62
  tmux attach-session -t test
@@ -34,3 +34,17 @@ Feature: Handling various errors with relevant messages
34
34
  """
35
35
  echo Unable to find blueprint named test_sample.yml
36
36
  """
37
+
38
+ Scenario: Trying incorrect blueprint opts
39
+ Given I have the following blueprint named "test_sample"
40
+ """
41
+ name: opt-less
42
+ root: '-r'
43
+ """
44
+ When Automux processes the blueprint "test_sample" with the following options
45
+ | option | value |
46
+ | -n | test |
47
+ Then the rendered sequence of shell commands should contain
48
+ """
49
+ echo Incorrect option passed. Try -h to check valid options.
50
+ """
@@ -33,7 +33,7 @@ In order to run the shell commands matching the given blueprint
33
33
  tmux start-server
34
34
  tmux new-session -d -s test
35
35
 
36
- tmux new-window -t test:2 2> /dev/null
36
+ tmux move-window -t test:2
37
37
  tmux rename-window -t test:2 editor
38
38
 
39
39
  tmux send-keys -t test:2 "ls" C-m
@@ -43,15 +43,15 @@ In order to run the shell commands matching the given blueprint
43
43
  tmux send-keys -t test:2 "pwd" C-m
44
44
  tmux select-layout -t test:2 main-vertical
45
45
 
46
- tmux new-window -t test:3 2> /dev/null
46
+ tmux new-window -t test:3
47
47
  tmux rename-window -t test:3 htop
48
48
  tmux send-keys -t test:3 "htop" C-m
49
49
 
50
- tmux new-window -t test:1 2> /dev/null
50
+ tmux new-window -t test:1
51
51
  tmux rename-window -t test:1 tester
52
52
  tmux send-keys -t test:1 "pwd" C-m
53
53
 
54
- tmux new-window -t test:0 2> /dev/null
54
+ tmux new-window -t test:0
55
55
  tmux rename-window -t test:0 zero
56
56
  tmux send-keys -t test:0 "pwd" C-m
57
57
  tmux split-window
@@ -81,11 +81,11 @@ In order to run the shell commands matching the given blueprint
81
81
  tmux start-server
82
82
  tmux new-session -d -s test
83
83
 
84
- tmux new-window -t test:1 2> /dev/null
84
+ tmux move-window -t test:1
85
85
  tmux rename-window -t test:1 editor
86
86
  tmux send-keys -t test:1 "vim" C-m
87
87
 
88
- tmux new-window -t test:1 2> /dev/null
88
+ tmux new-window -t test:1
89
89
  tmux rename-window -t test:1 top
90
90
  tmux send-keys -t test:1 "top" C-m
91
91
 
@@ -123,7 +123,7 @@ In order to run the shell commands matching the given blueprint
123
123
  tmux start-server
124
124
  tmux new-session -d -s name-less
125
125
 
126
- tmux new-window -t name-less:0 2> /dev/null
126
+ tmux move-window -t name-less:0
127
127
  tmux send-keys -t name-less:0 "git pull origin master" C-m
128
128
 
129
129
  tmux attach-session -t name-less
@@ -145,7 +145,7 @@ In order to run the shell commands matching the given blueprint
145
145
  tmux start-server
146
146
  tmux -u2 new-session -d -s flagged
147
147
 
148
- tmux new-window -t flagged:0 2> /dev/null
148
+ tmux move-window -t flagged:0
149
149
  tmux send-keys -t flagged:0 "vim" C-m
150
150
 
151
151
  tmux -u2 attach-session -t flagged
@@ -169,11 +169,11 @@ In order to run the shell commands matching the given blueprint
169
169
  tmux start-server
170
170
  tmux new-session -d -s test
171
171
 
172
- tmux new-window -t test:0 2> /dev/null
172
+ tmux move-window -t test:0
173
173
  tmux send-keys -t test:0 "cd projects" C-m
174
174
  tmux send-keys -t test:0 "vim" C-m
175
175
 
176
- tmux new-window -t test:1 2> /dev/null
176
+ tmux new-window -t test:1
177
177
  tmux send-keys -t test:1 "top" C-m
178
178
 
179
179
  tmux attach-session -t test
@@ -25,11 +25,11 @@ Feature: Using pre and post hooks for session
25
25
  tmux start-server
26
26
  tmux new-session -d -s hooked
27
27
 
28
- tmux new-window -t hooked:0 2> /dev/null
28
+ tmux move-window -t hooked:0
29
29
  tmux rename-window -t hooked:0 one
30
30
  tmux send-keys -t hooked:0 "" C-m
31
31
 
32
- tmux new-window -t hooked:1 2> /dev/null
32
+ tmux new-window -t hooked:1
33
33
  tmux rename-window -t hooked:1 two
34
34
  tmux send-keys -t hooked:1 "" C-m
35
35
 
@@ -65,10 +65,10 @@ Feature: Using pre and post hooks for session
65
65
  tmux start-server
66
66
  tmux new-session -d -s hooked
67
67
 
68
- tmux new-window -t hooked:0 2> /dev/null
68
+ tmux move-window -t hooked:0
69
69
  tmux send-keys -t hooked:0 "pwd" C-m
70
70
 
71
- tmux new-window -t hooked:1 2> /dev/null
71
+ tmux new-window -t hooked:1
72
72
  tmux rename-window -t hooked:1 echoed-window
73
73
 
74
74
  tmux send-keys -t hooked:1 "echo echoed-window start" C-m
@@ -42,7 +42,7 @@ Feature: Providing runtime options for blueprints
42
42
  tmux start-server
43
43
  tmux new-session -d -s test
44
44
 
45
- tmux new-window -t test:0 2> /dev/null
45
+ tmux move-window -t test:0
46
46
  tmux rename-window -t test:0 git
47
47
  tmux send-keys -t test:0 "git pull origin master" C-m
48
48
 
@@ -72,11 +72,11 @@ Feature: Providing runtime options for blueprints
72
72
  tmux start-server
73
73
  tmux new-session -d -s test
74
74
 
75
- tmux new-window -t test:0 2> /dev/null
75
+ tmux move-window -t test:0
76
76
  tmux rename-window -t test:0 vim
77
77
  tmux send-keys -t test:0 "vim" C-m
78
78
 
79
- tmux new-window -t test:1 2> /dev/null
79
+ tmux new-window -t test:1
80
80
  tmux rename-window -t test:1 top
81
81
  tmux send-keys -t test:1 "top" C-m
82
82
 
@@ -26,7 +26,7 @@ Feature: Handling session/window specific options
26
26
  tmux set-option status-left '#S>'
27
27
  tmux set-option status 'off'
28
28
 
29
- tmux new-window -t test:0 2> /dev/null
29
+ tmux move-window -t test:0
30
30
  tmux send-keys -t test:0 "pwd" C-m
31
31
 
32
32
  tmux set-window-option -t test:0 automatic-rename 'off'
@@ -57,10 +57,10 @@ Feature: Handling session/window specific options
57
57
 
58
58
  tmux set-option base-index '2'
59
59
 
60
- tmux new-window -t test:2 2> /dev/null
60
+ tmux move-window -t test:2
61
61
  tmux send-keys -t test:2 "pwd" C-m
62
62
 
63
- tmux new-window -t test:3 2> /dev/null
63
+ tmux new-window -t test:3
64
64
  tmux send-keys -t test:3 "ls" C-m
65
65
 
66
66
  tmux attach-session -t test
@@ -44,13 +44,26 @@ module Automux
44
44
  end
45
45
 
46
46
  def new_window(window)
47
- %[tmux new-window -t #{ name }:#{ window.index } 2> /dev/null]
47
+ %[tmux new-window -t #{ name }:#{ window.index }]
48
+ end
49
+
50
+ # The first window is created alongwith new-session and thus needs to be moved to its correct index.
51
+ def move_first_window_or_create_new(window)
52
+ if window == windows.first
53
+ move_window(window.index)
54
+ else
55
+ new_window(window)
56
+ end
48
57
  end
49
58
 
50
59
  def rename_window(window, window_name = window.name)
51
60
  %[tmux rename-window -t #{ name }:#{ window.index } #{ window_name }]
52
61
  end
53
62
 
63
+ def move_window(index)
64
+ %[tmux move-window -t #{ name }:#{ index }]
65
+ end
66
+
54
67
  def send_keys(identifier, command)
55
68
  window = get_window(identifier)
56
69
  %[tmux send-keys -t #{ name }:#{ window.index } "#{ command }" C-m]
@@ -30,7 +30,7 @@ module Automux
30
30
 
31
31
  # Scan for patterns like "-\w" or '-\w' to get a opts list.
32
32
  def get_file_opts(path)
33
- File.read(path).scan(/['|"](-\w:?)['|"]/m).flatten
33
+ File.read(path).scan(/(?<='|")-\w:?(?='|")/m)
34
34
  end
35
35
  end
36
36
  end
@@ -18,6 +18,8 @@ module Automux
18
18
  def get_options
19
19
  blueprint = Automux::Cache::Blueprint.find_by_name(blueprint_name)
20
20
  Automux::Library::FileOptionsParser.new(blueprint.path).getopts
21
+ rescue OptionParser::InvalidOption
22
+ Automux::Controller::Messages.new(message: 'Incorrect option passed. Try -h to check valid options.').error
21
23
  end
22
24
 
23
25
  def params
@@ -1,5 +1,5 @@
1
1
  module Automux
2
2
  module Version
3
- STRING = '0.3.0'
3
+ STRING = '0.3.1'
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
- printf "\033[0;31m"
1
+ printf "\033[1;31m"
2
2
  echo <%= message %>
3
3
  printf "\033[0m"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: automux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-07 00:00:00.000000000 Z
12
+ date: 2013-07-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Highly configurable Tmux Automator
15
15
  email: