vmfloaty 0.7.8 → 0.7.9

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: 1276bc1708aeaed0989e57cf71cdb5285a30e056
4
- data.tar.gz: 31548a5160989a07c5e90535231a2bc3644bba5b
3
+ metadata.gz: 4c7884840968e8735caff3146f276a2f9075cf79
4
+ data.tar.gz: 172f0dc34672fb184d62bb4dc7eb93d306e9d413
5
5
  SHA512:
6
- metadata.gz: d506a2ce2c29fef29b45a81cef91c3e643ff9cd9811a038ea601aeab9b9474715b08e2d31e4ce0d1e0c203115a52aa12760c70f33f841ecefc6de3a8342128d0
7
- data.tar.gz: 2fe79335fab27724c2a86d16f899f394390d0990fb0f6857c6d773dd4b56a0ba6ce61bc8957c9c6ac5428dad64da44e3b4dde6829467af0c482b6f88746e31b2
6
+ metadata.gz: ebfe08176a0505aa253849222afc98cf5b08361db264cee13fce6947b292434f1c466e23291fdee722b3b0cf658ac50335d61f78397190e3b489c237cab10806
7
+ data.tar.gz: 0d776b18978fb5fe8a1c893e1f2c1198fd78c7190561388eb7b1be334d79923ae0a39fa498e3007e7bc3c09834c05145cac5790195fa39c6c4e19d6f719254ae
data/README.md CHANGED
@@ -88,6 +88,22 @@ Here are the keys that vmfloaty currently supports:
88
88
  - url
89
89
  + String
90
90
 
91
+ ### Tab Completion
92
+
93
+ There is a basic completion script for Bash (and possibly other shells) included with the gem in the [extras/completions](https://github.com/briancain/vmfloaty/blob/master/extras/completions) folder. To activate, that file simply needs to be sourced somehow in your shell profile.
94
+
95
+ For convenience, the path to the completion script for the currently active version of the gem can be found with the `floaty completion` subcommand. This makes it easy to add the completion script to your profile like so:
96
+
97
+ ```bash
98
+ source $(floaty completion --shell bash)
99
+ ```
100
+
101
+ If you are running on macOS and use Homebrew's `bash-completion` formula, you can symlink the script to `/usr/local/etc/bash_completion.d/floaty` and it will be sourced automatically:
102
+
103
+ ```bash
104
+ ln -s $(floaty completion --shell bash) /usr/local/etc/bash_completion.d/floaty
105
+ ```
106
+
91
107
  ## vmpooler API
92
108
 
93
109
  This cli tool uses the [vmpooler API](https://github.com/puppetlabs/vmpooler/blob/master/API.md).
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env bash
2
+
3
+ _vmfloaty()
4
+ {
5
+ local cur prev subcommands template_subcommands hostname_subcommands
6
+ COMPREPLY=()
7
+ cur="${COMP_WORDS[COMP_CWORD]}"
8
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
9
+
10
+ subcommands="delete get help list modify query revert snapshot ssh status summary token"
11
+ template_subcommands="get ssh"
12
+ hostname_subcommands="delete modify query revert snapshot"
13
+
14
+ if [[ $cur == -* ]] ; then
15
+ # TODO: option completion
16
+ COMPREPLY=()
17
+ elif [[ $template_subcommands =~ (^| )$prev($| ) ]] ; then
18
+ if [[ -z "$_vmfloaty_avail_templates" ]] ; then
19
+ _vmfloaty_avail_templates=$(floaty list 2>/dev/null)
20
+ fi
21
+
22
+ COMPREPLY=( $(compgen -W "${_vmfloaty_avail_templates}" -- "${cur}") )
23
+ elif [[ $hostname_subcommands =~ (^| )$prev($| ) ]] ; then
24
+ _vmfloaty_active_hostnames=$(floaty list --active 2>/dev/null | grep '^-' | cut -d' ' -f2)
25
+ COMPREPLY=( $(compgen -W "${_vmfloaty_active_hostnames}" -- "${cur}") )
26
+ else
27
+ COMPREPLY=( $(compgen -W "${subcommands}" -- "${cur}") )
28
+ fi
29
+ }
30
+ complete -F _vmfloaty floaty
@@ -16,7 +16,7 @@ class Vmfloaty
16
16
  include Commander::Methods
17
17
 
18
18
  def run
19
- program :version, Version.get
19
+ program :version, Vmfloaty::VERSION
20
20
  program :description, 'A CLI helper tool for Puppet Labs vmpooler to help you stay afloat'
21
21
 
22
22
  config = Conf.read_config
@@ -75,7 +75,7 @@ class Vmfloaty
75
75
  STDERR.puts "You did not provide a user to authenticate to vmpooler with"
76
76
  exit 1
77
77
  end
78
- pass = password "Enter your password please:", '*'
78
+ pass = password "Enter your vmpooler password please:", '*'
79
79
  begin
80
80
  token = Auth.get_token(verbose, url, user, pass)
81
81
  rescue TokenError => e
@@ -479,7 +479,7 @@ class Vmfloaty
479
479
 
480
480
  case action
481
481
  when "get"
482
- pass = password "Enter your password please:", '*'
482
+ pass = password "Enter your vmpooler password please:", '*'
483
483
  begin
484
484
  token = Auth.get_token(verbose, url, user, pass)
485
485
  rescue TokenError => e
@@ -489,7 +489,7 @@ class Vmfloaty
489
489
  puts token
490
490
  exit 0
491
491
  when "delete"
492
- pass = password "Enter your password please:", '*'
492
+ pass = password "Enter your vmpooler password please:", '*'
493
493
  begin
494
494
  result = Auth.delete_token(verbose, url, user, pass, token)
495
495
  rescue TokenError => e
@@ -545,7 +545,7 @@ class Vmfloaty
545
545
  STDERR.puts "You did not provide a user to authenticate to vmpooler with"
546
546
  exit 1
547
547
  end
548
- pass = password "Enter your password please:", '*'
548
+ pass = password "Enter your vmpooler password please:", '*'
549
549
  begin
550
550
  token = Auth.get_token(verbose, url, user, pass)
551
551
  rescue TokenError => e
@@ -562,6 +562,32 @@ class Vmfloaty
562
562
  end
563
563
  end
564
564
 
565
+ command :completion do |c|
566
+ c.syntax = 'floaty completion [options]'
567
+ c.summary = 'Outputs path to completion script'
568
+ c.description = Utils.strip_heredoc(<<-EOF)
569
+ Outputs path to a completion script for the specified shell (or 'bash' if not specified). This makes it easy to add the completion script to your profile:
570
+
571
+ source $(floaty completion --shell bash)
572
+
573
+ This subcommand will exit non-zero with an error message if no completion script is available for the requested shell.
574
+ EOF
575
+ c.example 'Gets path to bash tab completion script', 'floaty completion --shell bash'
576
+ c.option '--shell STRING', String, 'Shell to request completion script for'
577
+ c.action do |args, options|
578
+ shell = (options.shell || 'bash').downcase.strip
579
+ completion_file = File.expand_path(File.join('..', '..', 'extras', 'completions', "floaty.#{shell}"), __FILE__)
580
+
581
+ if File.exist?(completion_file)
582
+ puts completion_file
583
+ exit 0
584
+ else
585
+ STDERR.puts "Could not find completion file for '#{shell}': No such file #{completion_file}"
586
+ exit 1
587
+ end
588
+ end
589
+ end
590
+
565
591
  run!
566
592
  end
567
593
  end
@@ -113,4 +113,12 @@ class Utils
113
113
  puts
114
114
  puts message.colorize(status['status']['ok'] ? :default : :red)
115
115
  end
116
+
117
+ # Adapted from ActiveSupport
118
+ def self.strip_heredoc(str)
119
+ min_indent = str.scan(/^[ \t]*(?=\S)/).min
120
+ min_indent_size = min_indent.nil? ? 0 : min_indent.size
121
+
122
+ str.gsub(/^[ \t]{#{min_indent_size}}/, '')
123
+ end
116
124
  end
@@ -1,8 +1,3 @@
1
-
2
- class Version
3
- @version = '0.7.8'
4
-
5
- def self.get
6
- @version
7
- end
1
+ class Vmfloaty
2
+ VERSION = '0.7.9'.freeze
8
3
  end
@@ -1,2 +1,8 @@
1
1
  require 'vmfloaty'
2
2
  require 'webmock/rspec'
3
+
4
+ RSpec.configure do |config|
5
+ config.color = true
6
+ config.tty = true
7
+ config.formatter = :documentation
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmfloaty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -16,40 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.3'
19
+ version: 4.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.3'
26
+ version: 4.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.9'
33
+ version: 0.9.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.9'
40
+ version: 0.9.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: colorize
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.8.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.8.1
55
55
  description: A helper tool for vmpooler to help you stay afloat
@@ -63,6 +63,7 @@ files:
63
63
  - LICENSE
64
64
  - README.md
65
65
  - bin/floaty
66
+ - extras/completions/floaty.bash
66
67
  - lib/vmfloaty.rb
67
68
  - lib/vmfloaty/auth.rb
68
69
  - lib/vmfloaty/conf.rb
@@ -78,7 +79,7 @@ files:
78
79
  - spec/vmfloaty/utils_spec.rb
79
80
  homepage: https://github.com/briancain/vmfloaty
80
81
  licenses:
81
- - Apache
82
+ - Apache-2.0
82
83
  metadata: {}
83
84
  post_install_message:
84
85
  rdoc_options: []
@@ -96,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
97
  version: '0'
97
98
  requirements: []
98
99
  rubyforge_project:
99
- rubygems_version: 2.4.5.1
100
+ rubygems_version: 2.6.12
100
101
  signing_key:
101
102
  specification_version: 4
102
103
  summary: CLI application to interface with vmpooler