cf_completion 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MWEyZjliMWQzZWIxODEwMDkyMzhkODg5MjkwZmZlOWJiODQ0YTg4Mw==
5
+ data.tar.gz: !binary |-
6
+ MTlkYzU2ZDM5MGRlMDVjZTJiMzZjMTBkOWMwMzExYmFmMTc1NzkwMw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YjAxMmNhNDc1OGE0NzYwZmZlMjI3ODUzN2QxYTM3MGYwNDVlM2JkMmQ5N2Rh
10
+ Zjg1NzZiM2M1YzMxMjIwOTlhYjE2OTgzODcyYmIzM2UwNjk2M2NlODliNzQz
11
+ NDIzNDFmOWRiZjA1MzcxODk4NjcyMDY4Yzc2NzM1ZjA0NWRhZDg=
12
+ data.tar.gz: !binary |-
13
+ YjI5NjBmM2VlM2UzMzRiMWJjZDIyM2IxNzgxOTIxMzkyOTQ2OGVhZWZiNzYw
14
+ MjJiZTNjYWIyYjMyNWQ3ZDI1ZjRmYzZiODk3Y2I5N2MwNTdjZWY3NTgwYzZi
15
+ MjNlZTRmMzYzMmY5MmRkMGI2MTdkYzI0N2M4YzU5YTYwZDQzMDQ=
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ *.gem
15
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cf_completion.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Rasheed Abdul-Aziz, Sai To Yeung and Pivotal Inc
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ cf_completion
2
+ =============
3
+
4
+ Bash completion for the Cloud Foundry CLI
5
+
6
+ Usage
7
+ =====
8
+
9
+ 1. Clone to your machine
10
+ 1. Edit _COMPLETION_LOCATION in cf_complete.sh to point to the checkout directory
11
+ 1. Add 'source path/to/cf_completion/cf_complete.sh' to your .bash_profile or similar startup scripts
12
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ if ENV['DEBUG_CF_COMPLETION']
3
+ $: << "./lib"
4
+ end
5
+
6
+ require 'cf_completion'
7
+
8
+ comp_line = ENV['COMP_LINE']
9
+ params = comp_line.split(' ')
10
+ comp_point = ENV['COMP_POINT'].to_i
11
+
12
+ completion_word_position = comp_line[0,comp_point].split(" ").count - 1
13
+
14
+ if comp_line[comp_point-1] == " "
15
+ completion_word_position += 1
16
+ end
17
+
18
+ completion_word = params[completion_word_position]
19
+
20
+ if ENV['DEBUG_CF_COMPLETION']
21
+ puts "Word Pos: #{completion_word_position}"
22
+ puts "Completion word: #{completion_word}"
23
+ puts "Params: #{params.join(", ")}"
24
+ end
25
+
26
+ CfCompletion.complete(completion_word, completion_word_position, params)
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cf_completion/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cf_completion"
8
+ spec.version = CfCompletion::VERSION
9
+ spec.authors = ["Sai To Yeung and Rasheed Abdul-Aziz"]
10
+ spec.email = ["pair+squeedee+syeung@pivotal.io"]
11
+ spec.summary = %q{Bash completion for the Cloud Foundry CLI}
12
+ spec.description = %q{Bash completion for the Cloud Foundry CLI}
13
+ spec.homepage = "https://github.com/cf-buildpacks/cf_completion"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.post_install_message =<<-POST_INSTALL_MESSAGE
22
+ *************
23
+ cf_complete installed!
24
+
25
+ To activate cf autocompletions, run the following line:
26
+
27
+ echo "complete -C cf_completion cf" >> ~/.bash_profile
28
+ POST_INSTALL_MESSAGE
29
+ end
@@ -0,0 +1,55 @@
1
+ require "cf_completion/version"
2
+
3
+ module CfCompletion
4
+
5
+ CF_COMMAND_POSITION = 1
6
+ APP_COMMANDS= %w{ app push p scale delete d rename start st stop sp restart rs
7
+ restage rg events files f logs env e set-env se unset-env stacks }
8
+
9
+ def self.complete(completion_word, completion_word_position, params)
10
+ command_name = command_name(completion_word_position, params)
11
+
12
+ if completion_word_position == CF_COMMAND_POSITION
13
+ puts list_commands(completion_word)
14
+ elsif APP_COMMANDS.include?(command_name) && completion_word_position == 2
15
+ puts list_apps(completion_word)
16
+ end
17
+ end
18
+
19
+ def self.command_name(completion_word_position, params)
20
+ return '' unless completion_word_position > CF_COMMAND_POSITION
21
+ params[CF_COMMAND_POSITION]
22
+ end
23
+
24
+ def self.list_commands(filter)
25
+ help_output = `cf help | sed -n '/^GETTING STARTED:/,/^ENVIRONMENT VARIABLES/p'`
26
+
27
+ help_output.
28
+ split("\n").
29
+ map { |line| line.match(/^\s+([^, ]*)/) }.
30
+ reject { |match| match.nil? }.
31
+ map { |match| match[1] }.
32
+ reject { |match| match[/^#{filter}/].nil? }
33
+ end
34
+
35
+ def self.list_apps(filter)
36
+ app_list = `cf apps`
37
+
38
+ found_heading = false
39
+
40
+ heading_search = ->(line) do
41
+ if (!found_heading && !line[/^name/].nil?)
42
+ found_heading = true
43
+ false
44
+ else
45
+ found_heading
46
+ end
47
+ end
48
+
49
+ app_list.
50
+ split("\n").
51
+ select(&heading_search).
52
+ map { |line| line.split(" ")[0] }.
53
+ select { |name| name[/^#{filter}/] }
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module CfCompletion
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cf_completion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sai To Yeung and Rasheed Abdul-Aziz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Bash completion for the Cloud Foundry CLI
14
+ email:
15
+ - pair+squeedee+syeung@pivotal.io
16
+ executables:
17
+ - cf_completion
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - bin/cf_completion
27
+ - cf_completion.gemspec
28
+ - lib/cf_completion.rb
29
+ - lib/cf_completion/version.rb
30
+ homepage: https://github.com/cf-buildpacks/cf_completion
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message: ! '*************
35
+
36
+ cf_complete installed!
37
+
38
+
39
+ To activate cf autocompletions, run the following line:
40
+
41
+
42
+ echo "complete -C cf_completion cf" >> ~/.bash_profile
43
+
44
+ '
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.4.3
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Bash completion for the Cloud Foundry CLI
64
+ test_files: []