shaft 0.7 → 0.8

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.
data/README.md CHANGED
@@ -22,14 +22,14 @@ As easy as:
22
22
 
23
23
  ## Usage
24
24
 
25
- Your tunnel configurations need to be stored as
26
- [YAML](http://www.yaml.org) files on your `~/.shaft/` dir.
25
+ Your tunnel configurations need to be stored as records in
26
+ a [YAML](http://www.yaml.org) formatted `~/.shaft` file.
27
27
 
28
28
  See 'Configuration' for instructions on how to format these
29
29
  files.
30
30
 
31
31
  * Use `shaft all` to get a list of all available tunnels.
32
- * Use `shaft list` to see which tunnels are currently active.
32
+ * Use `shaft active` to see which tunnels are currently active.
33
33
  - You could use the `--short` option to get only the names
34
34
  of those lines (this could be useful to insert into your
35
35
  shell prompt. Just saying).
@@ -60,6 +60,17 @@ to running:
60
60
 
61
61
  $ ssh -N -p 22 user@remote-host -L 9999:host:8888
62
62
 
63
+ ## ZSH Completions
64
+
65
+ Shaft includes a setup file for automatic completion of tunnel names if you use the ZSH shell.
66
+
67
+ To install it, you can run:
68
+
69
+ $ shaft completions >> ~/.zshrc
70
+
71
+ (Or output it to any file that your `.zshrc` includes).
72
+ Don't forget to restart your shell!
73
+
63
74
  ## Contributing
64
75
 
65
76
  1. Fork it
data/bin/shaft CHANGED
@@ -19,7 +19,7 @@ class ShaftCLI < Thor
19
19
  active = get_active
20
20
  unless active.empty?
21
21
  if options[:short]
22
- say active.keys.join(",")
22
+ say active.keys.join(" ")
23
23
  else
24
24
  say "Listing currently active tunnels:"
25
25
  print_table active
@@ -30,10 +30,22 @@ class ShaftCLI < Thor
30
30
  end
31
31
 
32
32
  desc "all", "Lists all available tunnels"
33
+ method_options %w( short -s ) => :boolean
33
34
  def all
34
- say "Listing all available tunnels:"
35
35
  tunnels = get_config.keys
36
- print_in_columns tunnels
36
+ if options[:short]
37
+ say tunnels.join(' ')
38
+ else
39
+ say "Listing all available tunnels:"
40
+ print_in_columns tunnels
41
+ end
42
+ end
43
+
44
+ desc "completions", "Prints setup code for Zsh completions"
45
+ def completions
46
+ fpath = File.expand_path File.join(File.dirname(__FILE__), '..', 'completions')
47
+ puts "fpath=(#{fpath} $fpath)"
48
+ puts "compinit"
37
49
  end
38
50
 
39
51
  desc "start [NAME]", "Starts a tunnel"
@@ -0,0 +1,29 @@
1
+ #compdef shaft
2
+
3
+ _shaft() {
4
+ local curcontext="$curcontext" state line
5
+ typeset -A opt_args
6
+
7
+ _arguments \
8
+ '1: :->command'\
9
+ '*: :->tunnel'
10
+
11
+
12
+ case $state in
13
+ command)
14
+ _arguments "1:Commands:(active start stop restart help all completions)"
15
+ ;;
16
+ *)
17
+ case $words[2] in
18
+ start)
19
+ compadd "$@" `shaft all --short`
20
+ ;;
21
+ stop|restart)
22
+ compadd "$@" `shaft active --short`
23
+ ;;
24
+ esac
25
+ ;;
26
+ esac
27
+ }
28
+
29
+ _shaft "$@"
@@ -1,3 +1,3 @@
1
1
  module Shaft
2
- VERSION = "0.7"
2
+ VERSION = "0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shaft
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: '0.8'
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-01-20 00:00:00.000000000 Z
12
+ date: 2013-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -41,6 +41,7 @@ files:
41
41
  - README.md
42
42
  - Rakefile
43
43
  - bin/shaft
44
+ - completions/_shaft
44
45
  - lib/shaft.rb
45
46
  - lib/shaft/version.rb
46
47
  - shaft.gemspec