vscripts 0.0.1 → 0.0.2
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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +5 -0
- data/README.md +3 -2
- data/VERSION +1 -1
- data/lib/vscripts.rb +3 -3
- data/lib/vscripts/command_line.rb +16 -22
- data/lib/vscripts/commands/tags2facts.rb +7 -7
- data/spec/vscripts/command_line_spec.rb +2 -2
- data/tasks/deploy.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 284b7ce118690580cd9971867304a34b6c488446
|
4
|
+
data.tar.gz: cf23021865d435cc5e18925343ab3bb6fa06e743
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dc8f5dc252f51cd35d1b5d2a5f9b167426f801a2fa6e677bf19c391d9e7907aa13005e83372a82dc269daac167962d1ce1b964a1fd1dfc0a580ba50a7662ba4
|
7
|
+
data.tar.gz: 298543beafca0f797fe2a0702a882fe249edce68887f7ca4dc53df6c42ef2953929dab90d10b65c27fcfa271b600172c4c680fdf757810e97549c7b250c4d4f6
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 0.0.2
|
2
|
+
---
|
3
|
+
* Fix command line options ([Vlad - efa8c95](https://github.com/vghn/vscripts/commit/efa8c959176da8ca95f13ef4433eb7468ecfaea8))
|
4
|
+
* Minor fixes ([Vlad - b3cecf1](https://github.com/vghn/vscripts/commit/b3cecf14a614ce561e98345378c4cfc25f9b0c44))
|
5
|
+
|
1
6
|
Version 0.0.1
|
2
7
|
---
|
3
8
|
* Create gem structure ([Vlad - 635a06d](https://github.com/vghn/vscripts/commit/635a06d33fab5e8dbee39991ffc1e7bbf4ef4e6f))
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# VScripts
|
2
2
|
[](https://travis-ci.org/vghn/vscripts)
|
3
3
|
[](https://codeclimate.com/github/vghn/vscripts)
|
4
|
+
[](http://badge.fury.io/rb/vscripts)
|
4
5
|
|
5
6
|
Automation daemon.
|
6
7
|
|
@@ -23,14 +24,14 @@ vscripts GLOBAL-OPTIONS COMMAND OPTIONS
|
|
23
24
|
```
|
24
25
|
|
25
26
|
|
26
|
-
### Global Options
|
27
|
+
### Global Options
|
27
28
|
```
|
28
29
|
-h|--help: Displays VScripts help.
|
29
30
|
-v|--version: Displays the version number.
|
30
31
|
```
|
31
32
|
|
32
33
|
|
33
|
-
### Commands
|
34
|
+
### Commands
|
34
35
|
|
35
36
|
1. **Tags2Facts**
|
36
37
|
This command can only be run on an AWS EC2 instance. It looks for all tags
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/vscripts.rb
CHANGED
@@ -4,9 +4,9 @@ require 'vscripts/command_line'
|
|
4
4
|
# Main VScripts module
|
5
5
|
module VScripts
|
6
6
|
# Gets the command name from command line and calls the right class.
|
7
|
-
def self.run(
|
8
|
-
cli
|
9
|
-
command = VScripts::Commands.const_get(cli.command).new(
|
7
|
+
def self.run(argv)
|
8
|
+
cli = CommandLine.new(argv)
|
9
|
+
command = VScripts::Commands.const_get(cli.command).new(cli.arguments)
|
10
10
|
command.execute
|
11
11
|
end
|
12
12
|
end # module VScripts
|
@@ -4,32 +4,32 @@ require 'vscripts/command'
|
|
4
4
|
module VScripts
|
5
5
|
# Global Command Line
|
6
6
|
class CommandLine
|
7
|
+
# @return [Array] All the command line arguments
|
8
|
+
attr_accessor :arguments
|
7
9
|
# @return [Hash] Global command line arguments
|
8
10
|
attr_reader :global
|
9
11
|
# @return [String] Command name
|
10
12
|
attr_reader :command
|
11
|
-
# @return [Array] Extra arguments passed to the command
|
12
|
-
attr_reader :extra
|
13
13
|
|
14
14
|
# Build command line arguments
|
15
|
-
def initialize(
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
15
|
+
def initialize(argv = [])
|
16
|
+
@arguments ||= argv
|
17
|
+
@global ||= parse_cli_options
|
18
|
+
@command ||= verify_command
|
19
19
|
end
|
20
20
|
|
21
21
|
# Specifies command line options
|
22
22
|
# This method smells of :reek:NestedIterators but ignores them
|
23
23
|
# This method smells of :reek:TooManyStatements but ignores them
|
24
24
|
def parser # rubocop:disable MethodLength
|
25
|
-
available = Command.list
|
26
|
-
Trollop::Parser.new do
|
25
|
+
available = Command.list.map { |cmd| cmd.to_s.downcase }
|
26
|
+
@parser ||= Trollop::Parser.new do
|
27
27
|
version VScripts::VERSION_C
|
28
28
|
banner <<-EOS
|
29
29
|
VScripts automation daemon.
|
30
30
|
|
31
31
|
Available commands:
|
32
|
-
#{available
|
32
|
+
#{available}
|
33
33
|
|
34
34
|
Usage:
|
35
35
|
vscripts GLOBAL-OPTIONS COMMAND OPTIONS
|
@@ -44,29 +44,23 @@ EOS
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# Parses command line arguments
|
47
|
-
def
|
47
|
+
def parse_cli_options
|
48
48
|
Trollop.with_standard_exception_handling parser do
|
49
|
-
fail Trollop::HelpNeeded if
|
50
|
-
parser.parse
|
49
|
+
fail Trollop::HelpNeeded if arguments.empty?
|
50
|
+
parser.parse arguments
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
# Ensure command is available
|
55
55
|
# @return [String] Command name
|
56
|
-
def
|
57
|
-
command_cli =
|
56
|
+
def verify_command
|
57
|
+
command_cli = arguments.shift
|
58
58
|
command_cls = command_cli.capitalize.to_sym
|
59
|
-
if
|
59
|
+
if Command.list.include?(command_cls)
|
60
60
|
return command_cls
|
61
61
|
else
|
62
|
-
|
63
|
-
exit 1
|
62
|
+
abort "Error: Unknown subcommand '#{command_cli}'\nTry --help."
|
64
63
|
end
|
65
64
|
end
|
66
|
-
|
67
|
-
# @return [Array] The rest of the arguments
|
68
|
-
def rest(args)
|
69
|
-
args
|
70
|
-
end
|
71
65
|
end # class CommandLine
|
72
66
|
end # module VScripts
|
@@ -29,13 +29,13 @@ module VScripts
|
|
29
29
|
Options:
|
30
30
|
EOS
|
31
31
|
|
32
|
-
# @return [
|
33
|
-
attr_reader :
|
32
|
+
# @return [Array] Command specific arguments
|
33
|
+
attr_reader :arguments
|
34
34
|
# @return [AWS::EC2] EC2 SDK
|
35
35
|
attr_reader :ec2
|
36
36
|
|
37
|
-
def initialize(
|
38
|
-
@
|
37
|
+
def initialize(argv = [])
|
38
|
+
@arguments ||= argv
|
39
39
|
@ec2 ||= VScripts::AWS::EC2.new
|
40
40
|
end
|
41
41
|
|
@@ -51,9 +51,9 @@ module VScripts
|
|
51
51
|
end
|
52
52
|
|
53
53
|
# Parses command line arguments
|
54
|
-
def
|
55
|
-
Trollop.with_standard_exception_handling parser do
|
56
|
-
parser.parse
|
54
|
+
def cli
|
55
|
+
@cli ||= Trollop.with_standard_exception_handling parser do
|
56
|
+
parser.parse arguments
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -27,8 +27,8 @@ describe VScripts::CommandLine do
|
|
27
27
|
|
28
28
|
describe '#extra' do
|
29
29
|
it 'returns the rest of the arguments as an Array' do
|
30
|
-
expect(@cli.
|
31
|
-
expect(@cli.
|
30
|
+
expect(@cli.arguments).to be_an_instance_of Array
|
31
|
+
expect(@cli.arguments).to eql ['extra_args']
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/tasks/deploy.rake
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vscripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Ghinea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|