vanagon 0.15.36 → 0.17.0

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -23
  3. data/bin/build +4 -25
  4. data/bin/build_host_info +4 -17
  5. data/bin/build_requirements +4 -31
  6. data/bin/inspect +4 -21
  7. data/bin/render +4 -22
  8. data/bin/ship +4 -28
  9. data/bin/sign +4 -11
  10. data/bin/vanagon +7 -0
  11. data/lib/vanagon.rb +1 -1
  12. data/lib/vanagon/cli.rb +94 -0
  13. data/lib/vanagon/cli/build.rb +75 -0
  14. data/lib/vanagon/cli/build_host_info.rb +49 -0
  15. data/lib/vanagon/cli/build_requirements.rb +60 -0
  16. data/lib/vanagon/cli/inspect.rb +65 -0
  17. data/lib/vanagon/cli/render.rb +51 -0
  18. data/lib/vanagon/cli/ship.rb +52 -0
  19. data/lib/vanagon/cli/sign.rb +34 -0
  20. data/lib/vanagon/driver.rb +11 -7
  21. data/lib/vanagon/engine/always_be_scheduling.rb +271 -1
  22. data/lib/vanagon/engine/docker.rb +101 -14
  23. data/lib/vanagon/engine/pooler.rb +7 -3
  24. data/lib/vanagon/platform.rb +5 -3
  25. data/lib/vanagon/platform/deb.rb +1 -1
  26. data/lib/vanagon/platform/dsl.rb +11 -0
  27. data/lib/vanagon/platform/rpm.rb +1 -1
  28. data/lib/vanagon/platform/windows.rb +29 -2
  29. data/lib/vanagon/project.rb +23 -4
  30. data/lib/vanagon/project/dsl.rb +33 -0
  31. data/lib/vanagon/utilities.rb +30 -8
  32. data/resources/rpm/project.spec.erb +3 -0
  33. data/spec/lib/vanagon/cli_spec.rb +80 -0
  34. data/spec/lib/vanagon/engine/always_be_scheduling_spec.rb +113 -1
  35. data/spec/lib/vanagon/engine/docker_spec.rb +74 -16
  36. data/spec/lib/vanagon/engine/ec2_spec.rb +2 -0
  37. data/spec/lib/vanagon/engine/pooler_spec.rb +1 -1
  38. data/spec/spec_helper.rb +1 -0
  39. metadata +56 -33
  40. data/lib/vanagon/optparse.rb +0 -86
  41. data/spec/lib/vanagon/optparse_spec.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3da7ab177127a9c8735a304f2abbbbcbfa2dc2244b389e3cc4c3c3e440c66e17
4
- data.tar.gz: c8b21d1f75c57e10598907a8ca2f5c937f2d96a041d6ad5876f578ab67dca96a
3
+ metadata.gz: e09a1563ed504da68687d85b7c7a70e62028b7d1ba24568476d5cae338ae1ebf
4
+ data.tar.gz: 9da1804bfbf40c86ac845ccf60a76c133b217357117dcd22d43d97c35299aa1d
5
5
  SHA512:
6
- metadata.gz: 3a3d603bacbc6f4588ae915cc9bd36dfcceba404ef75a4da4fb12429956f3aa5def4ab3b7db99eaa88865eda2870bec3d691f882eab1a2e2727a2a203f3b931b
7
- data.tar.gz: 54b68ba89cbfe3dcc0d800c248f743258f4da9000696d79687cbe2da38543f02b0cf83dd4f214eaa1ecc90015b4dc5b27a69e64496d2d5100686507b4ce6c8a7
6
+ metadata.gz: 19591339a372853aa653311214de761ead6dfd173218d68c0086691ede75da8d981079408afaf04e5fd362e2c9250c72ac9b1cb8cc3fdbeb16006a6510707176
7
+ data.tar.gz: 74e995f55e05778820809bbed4c2dcd501896a8d4894e1a38921bb8057cee049d62c42e136e8929c84c9609790738d77be356ed55b499974b3399c6a032d724c
data/README.md CHANGED
@@ -45,9 +45,10 @@ Also, Vanagon ships with a number of engines which may include additional option
45
45
 
46
46
  ### Local Host:
47
47
 
48
- - [Ruby](https://www.ruby-lang.org/en/) (Ruby 2.1.x is the miniumum supported version)
48
+ - [Ruby](https://www.ruby-lang.org/en/) (Ruby 2.3.x is the miniumum supported version)
49
49
  - [fustigit](https://github.com/mckern/fustigit)
50
50
  - [ruby-git](https://github.com/schacon/ruby-git)
51
+ - [docopt](https://github.com/docopt/docopt.rb)
51
52
  - The command line tool `ssh` ([homepage](https://www.openssh.com/)) available on the local `${PATH}` (any modern version should suffice)
52
53
  - The command line tool `rsync` ([homepage](https://rsync.samba.org/)) available on the local `${PATH}` (At least rsync 2.6.x)
53
54
  - The command line tool `git` ([homepage](https://git-scm.com/)) available on the local `${PATH}` (Vanagon is tested against Git version 1.8.x but should work with any newer version)
@@ -84,10 +85,28 @@ wheezy and build my project against it.
84
85
  For more detailed examples of the DSLs available, please see the
85
86
  [examples](examples) directory and the YARD documentation for Vanagon.
86
87
 
87
- ### `build` usage
88
+ ### CLI changes and deprecations (from version 0.16.0)
89
+
90
+ Prior to 0.16.0, the vanagon command line contained these commands
91
+
92
+ * `build`
93
+ * `build_host_info`
94
+ * `build_requirements`
95
+ * `inspect`
96
+ * `render`
97
+ * `repo`
98
+ * `ship`
99
+ * `sign`
100
+
101
+ With the exception of `repo`, which calls `packaging` methods, the remaining commands
102
+ have been moved to a git-like pattern of `vanagon <subcommand>`. `vangon build` replaced `build`, `vanagon ship` replaced `ship` and so forth.
103
+
104
+ The older calling usage is deprecated.
105
+
106
+ ### `vanagon build` usage
88
107
  The build command has positional arguments and position independent flags.
89
108
 
90
- #### Arguments (position dependent)
109
+ #### Positional arguments
91
110
 
92
111
  ##### project name
93
112
  The name of the project to build; a file named `<project_name>.rb` must be
@@ -114,7 +133,8 @@ Build machines should be cleaned between builds.
114
133
 
115
134
  #### Flagged arguments
116
135
 
117
- **Note:** command flags can be used anywhere in the command.
136
+ **Note:** command flags currently can be used anywhere in the command. Recommended usages
137
+ is to use flagged arguments before the positional arguments.
118
138
 
119
139
  ##### -w DIR, --workdir DIR
120
140
  Specifies a directory on the local host where the sources should be placed and builds performed.
@@ -134,9 +154,10 @@ Currently supported engines are:
134
154
  * `base` - Pure ssh backend; no teardown currently defined
135
155
  * `local` - Build on the local machine; platform name must match the local machine
136
156
  * `docker` - Builds in a docker container
137
- * `pooler` - Selects a vm from Puppet Labs' vm pooler to build on
157
+ * `pooler` - Selects a vm from Puppet's internal vmpooler to build on
138
158
  * `hardware` - Build on a specific taget and lock it in redis
139
159
  * `ec2` - Build on a specific AWS instance.
160
+ * `ABS` - Selects a vm from Puppet's internal Always-be-scheduling service to build on
140
161
 
141
162
  #### Flags
142
163
 
@@ -147,9 +168,6 @@ Indicates that the host used for building the project should be left intact
147
168
  after the build instead of destroyed. The host is usually destroyed after a
148
169
  successful build, or left after a failed build.
149
170
 
150
- ##### -v, --verbose
151
- (Reserved for future implementation) Will increase the verbosity of output, when implemented.
152
-
153
171
  ##### -h, --help
154
172
  Display command-line help.
155
173
 
@@ -195,16 +213,16 @@ integer value these components to fail after the `VANAGON_TIMEOUT` count is reac
195
213
  Note that this value is expected to be in seconds.
196
214
 
197
215
  #### Example usage
198
- `build --preserve puppet-agent el-6-i386` will build the puppet-agent project
216
+ `vanagon build --preserve puppet-agent el-6-i386` will build the puppet-agent project
199
217
  on the el-6-i386 platform and leave the host intact afterward.
200
218
 
201
- `build --engine=docker puppet-agent el-6-i386` will build the puppet-agent
219
+ `vanagon build --engine=docker puppet-agent el-6-i386` will build the puppet-agent
202
220
  project on the el-6-i386 platform using the docker engine (the platform must
203
221
  have a docker\_image defined in its config).
204
222
 
205
223
  ---
206
224
 
207
- ### `inspect` usage
225
+ ### `vanagon inspect` usage
208
226
 
209
227
  The `inspect` command has positional arguments and position independent flags. It
210
228
  mirrors the `build` command, but exits with success after loading and interpolating
@@ -212,7 +230,7 @@ all of the components in the given project. No attempt is made to actually build
212
230
  the given project; instead, a JSON formatted array of hashes is returned and printed
213
231
  to `stdout`. This JSON array can be further processed by external tooling, such as `jq`.
214
232
 
215
- #### Arguments (position dependent)
233
+ #### Positional arguments
216
234
 
217
235
  ##### project name
218
236
  The name of the project to build, and a file named \<project\_name\>.rb must be
@@ -227,7 +245,8 @@ Platform can also be a comma separated list of platforms such as platform1,platf
227
245
 
228
246
  #### Flagged arguments
229
247
 
230
- **Note:** command flags can be used anywhere in the command.
248
+ **Note:** command flags currently can be used anywhere in the command. Recommended usages
249
+ is to use flagged arguments before the positional arguments.
231
250
 
232
251
  ##### -w DIR, --workdir DIR
233
252
  Specifies a directory where the sources should be placed and builds performed.
@@ -239,29 +258,24 @@ Specifies where project configuration is found. Defaults to $pwd/configs.
239
258
  ##### -e ENGINE, --engine ENGINE
240
259
  Choose a different virtualization engine to use to select the build target.
241
260
  Engines are respected, but only insofar as components and projects are
242
- rendered -- the `inspect` command performs no compilation.
261
+ rendered -- the `vanagon inspect` command performs no compilation.
243
262
 
244
- Supported engines are the same as the `build` command.
263
+ Supported engines are the same as the `vanagon build` command.
245
264
 
246
265
  #### Flags
247
266
 
248
- **Note:** command flags can be used anywhere in the command.
249
-
250
- ##### -v, --verbose (not yet implemented)
251
- Increase verbosity of output.
252
-
253
267
  ##### -h, --help
254
268
  Display command-line help.
255
269
 
256
270
  #### Environment variables
257
271
 
258
272
  Environment variables are respected, but only insofar as components and projects are
259
- rendered -- the `inspect` command has no behavior to alter.
273
+ rendered -- the `vanagon inspect` command has no behavior to alter.
260
274
 
261
- Supported environment variables are the same as the `build` command.
275
+ Supported environment variables are the same as the `vanagon build` command.
262
276
 
263
277
  #### Example usage
264
- `inspect puppet-agent el-6-i386` will load the puppet-agent project
278
+ `vanagon inspect puppet-agent el-6-i386` will load the puppet-agent project
265
279
  on the el-6-i386 platform and print the resulting list of dependencies,
266
280
  build-time configuration, environment variables, and expected artifacts.
267
281
 
@@ -297,6 +311,16 @@ platform "el-7-x86_64" do |plat|
297
311
  end
298
312
  ```
299
313
 
314
+ ### ABS (internal)
315
+ When using the ABS engine, there is a variety of ways you can specify your token:
316
+ - the environment variable ABS_TOKEN
317
+ - or vanagon token file ~/.vanagon-token (note this is the same file read by the pooler engine)
318
+ - or [vmfloaty](https://github.com/puppetlabs/vmfloaty)'s config file ~/.vmfloaty.yml
319
+
320
+ In order to modify or track the VM via floaty or bit-bar you can optionally add the vmpooler token (different from the ABS token) via
321
+ - VMPOOLER_TOKEN
322
+ - or as a second line to the file ~/.vanagon-token
323
+ - or by using the existing mechanism in floaty using a vmpooler_fallback
300
324
 
301
325
  Contributing
302
326
  ---
@@ -310,3 +334,4 @@ See [LICENSE](LICENSE) file.
310
334
 
311
335
  ## Maintainers
312
336
  See [MAINTAINERS](MAINTAINERS) file.
337
+
data/bin/build CHANGED
@@ -1,29 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
2
 
4
- optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name>[,<platform-name>...] [<target>,<target>...] [options]",
5
- %i[workdir configdir engine preserve verbose skipcheck only_build remote-workdir])
6
- options = optparse.parse! ARGV
3
+ script = File.basename($0)
7
4
 
8
- project = ARGV[0]
9
- platforms = ARGV[1]
10
- targets = ARGV[2]
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
11
7
 
12
- if project.nil? or platforms.nil?
13
- warn "project and platform are both required arguments."
14
- warn optparse
15
- exit 1
16
- end
17
-
18
- platform_list = platforms.split(',')
19
- if targets
20
- target_list = targets.split(',')
21
- else
22
- target_list = []
23
- end
24
-
25
- platform_list.zip(target_list).each do |pair|
26
- platform, target = pair
27
- artifact = Vanagon::Driver.new(platform, project, options.merge({ :target => target }))
28
- artifact.run
29
- end
8
+ exec "vanagon", script, *ARGV
@@ -1,21 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require 'json'
3
2
 
4
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
+ script = File.basename($0)
5
4
 
6
- optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", %i[workdir configdir engine])
7
- options = optparse.parse! ARGV
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
8
7
 
9
- project = ARGV[0]
10
- platforms = ARGV[1]
11
-
12
- if project.nil? or platforms.nil?
13
- warn "project and platform are both required arguments."
14
- warn optparse
15
- exit 1
16
- end
17
-
18
- platforms.split(',').each do |platform|
19
- driver = Vanagon::Driver.new(platform, project, options)
20
- $stdout.puts JSON.generate(driver.build_host_info)
21
- end
8
+ exec "vanagon", script, *ARGV
@@ -1,35 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require 'json'
3
- require 'vanagon/extensions/ostruct/json'
4
- require 'vanagon/extensions/set/json'
5
- require 'vanagon/extensions/hashable'
6
2
 
7
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
+ script = File.basename($0)
8
4
 
9
- optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", %i[workdir configdir engine])
10
- optparse.parse! ARGV
11
-
12
- project = ARGV[0]
13
- platform = ARGV[1]
14
-
15
- unless project and platform
16
- warn "project and platform are both required arguments."
17
- warn optparse
18
- exit 1
19
- end
20
-
21
- driver = Vanagon::Driver.new(platform, project)
22
- components = driver.project.components
23
- component_names = components.map(&:name)
24
- build_requirements = []
25
- components.each do |component|
26
- build_requirements << component.build_requires.reject do |req|
27
- # only include external requirements: i.e. those that do not match
28
- # other components in the project
29
- component_names.include?(req)
30
- end
31
- end
32
- $stdout.puts
33
- $stdout.puts "**** External packages required to build #{project} on #{platform}: ***"
34
- $stdout.puts JSON.pretty_generate(build_requirements.flatten.uniq.sort)
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
35
7
 
8
+ exec "vanagon", script, *ARGV
@@ -1,25 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require 'json'
3
- require 'vanagon/extensions/ostruct/json'
4
- require 'vanagon/extensions/set/json'
5
- require 'vanagon/extensions/hashable'
6
2
 
7
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
+ script = File.basename($0)
8
4
 
9
- optparse = Vanagon::OptParse.new("#{File.basename(__FILE__)} <project-name> <platform-name> [options]", %i[workdir configdir engine])
10
- options = optparse.parse! ARGV
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
11
7
 
12
- project = ARGV[0]
13
- platforms = ARGV[1]
14
-
15
- unless project or platforms
16
- warn "project and platform are both required arguments."
17
- warn optparse
18
- exit 1
19
- end
20
-
21
- platforms.split(',').each do |platform|
22
- driver = Vanagon::Driver.new(platform, project, options)
23
- components = driver.project.components.map(&:to_hash)
24
- $stdout.puts JSON.pretty_generate(components)
25
- end
8
+ exec "vanagon", script, *ARGV
data/bin/render CHANGED
@@ -1,26 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
3
2
 
4
- optparse = Vanagon::OptParse.new(
5
- "#{File.basename(__FILE__)} <project-name> <platform-name> [options]",
6
- %i[workdir configdir engine]
7
- )
8
- options = optparse.parse! ARGV
3
+ script = File.basename($0)
9
4
 
10
- project = ARGV[0]
11
- platforms = ARGV[1]
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
12
7
 
13
- if project.nil? or platforms.nil?
14
- warn "project and platform are both required arguments."
15
- warn optparse
16
- exit 1
17
- end
18
-
19
- platform_list = platforms.split(',')
20
- target_list = []
21
-
22
- platform_list.zip(target_list).each do |pair|
23
- platform, target = pair
24
- artifact = Vanagon::Driver.new(platform, project, options.merge({ :target => target }))
25
- artifact.render
26
- end
8
+ exec "vanagon", script, *ARGV
data/bin/ship CHANGED
@@ -1,32 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ENV["PROJECT_ROOT"] = Dir.pwd
3
+ script = File.basename($0)
4
4
 
5
- # Begin warning: This ship script is an internal tool.
6
- # This is not intended to function outside of Puppet Labs' infrastructure.
7
- # End of warning.
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
8
7
 
9
- artifactory_warning = <<-DOC
10
- Unable to ship packages to artifactory. Please make sure you are pointing to a
11
- recent version of packaging in your Gemfile. Please also make sure you include
12
- the artifactory gem in your Gemfile.
13
-
14
- i.e.,
15
- gem 'packaging', :github => 'puppetlabs/packaging', branch: '1.0.x'
16
- gem 'artifactory'
17
- DOC
18
-
19
- if Dir["output/**/*"].select { |entry| File.file?(entry) }.empty?
20
- fail "No packages to ship in the output directory. Maybe you want to build some first?"
21
- else
22
- require 'packaging'
23
- Pkg::Util::RakeUtils.load_packaging_tasks
24
- Pkg::Util::RakeUtils.invoke_task('pl:jenkins:ship', 'artifacts', 'output')
25
- begin
26
- Pkg::Util::RakeUtils.invoke_task('pl:jenkins:ship_to_artifactory', 'output')
27
- rescue LoadError
28
- warn artifactory_warning
29
- rescue StandardError
30
- warn artifactory_warning
31
- end
32
- end
8
+ exec "vanagon", script, *ARGV
data/bin/sign CHANGED
@@ -1,15 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- ENV["PROJECT_ROOT"] = Dir.pwd
3
+ script = File.basename($0)
4
4
 
5
- # Begin warning: This sign script is an internal tool.
6
- # This is not intended to function outside of Puppet Labs' infrastructure.
7
- # End of warning.
5
+ warn "#{script}: Warning: use of stand alone '#{script}' command is deprecated and may be removed.
6
+ Use: 'vanagon #{script}' instead."
8
7
 
9
- if Dir["output/**/*"].select { |entry| File.file?(entry) }.empty?
10
- fail "No packages to sign in the output directory. Maybe you want to build some first?"
11
- end
12
-
13
- require 'packaging'
14
- Pkg::Util::RakeUtils.load_packaging_tasks
15
- Pkg::Util::RakeUtils.invoke_task('pl:jenkins:sign_all', 'output')
8
+ exec "vanagon", script, *ARGV
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "vanagon.rb"))
4
+
5
+ vanagon = Vanagon::CLI.new
6
+
7
+ vanagon.run(vanagon.parse(ARGV))
@@ -8,7 +8,7 @@ VANAGON_VERSION = Gem.loaded_specs["vanagon"].version.to_s
8
8
  $:.unshift(LIBDIR) unless
9
9
  $:.include?(File.dirname(__FILE__)) || $:.include?(LIBDIR)
10
10
 
11
- require 'vanagon/optparse'
11
+ require 'vanagon/cli'
12
12
  require 'vanagon/driver'
13
13
 
14
14
  # The main entry point is {Vanagon::Driver}.
@@ -0,0 +1,94 @@
1
+ require 'docopt'
2
+ require 'json'
3
+
4
+ require 'vanagon/extensions/ostruct/json'
5
+ require 'vanagon/extensions/set/json'
6
+ require 'vanagon/extensions/hashable'
7
+
8
+ require 'vanagon/cli/build'
9
+ require 'vanagon/cli/build_host_info'
10
+ require 'vanagon/cli/build_requirements'
11
+ require 'vanagon/cli/inspect'
12
+ require 'vanagon/cli/render'
13
+ require 'vanagon/cli/ship'
14
+ require 'vanagon/cli/sign'
15
+
16
+
17
+ class Vanagon
18
+ class InvalidArgument < StandardError
19
+ end
20
+
21
+ class CLI
22
+ DOCUMENTATION = <<~DOCOPT.freeze
23
+ Usage:
24
+ vanagon <command> [<args>]...
25
+
26
+ Commands are:
27
+ build build a package given a project and platform
28
+ build_host_info print information about build hosts
29
+ build_requirements print external packages required to build project
30
+ inspect a build dry-run, printing lots of information about the build
31
+ render create local versions of packaging artifacts for project
32
+ sign sign a package
33
+ ship upload a package to a distribution server
34
+ help print this help
35
+ DOCOPT
36
+
37
+ def parse(argv) # rubocop:disable Metrics/AbcSize
38
+ parsed_options = parse_options(argv)
39
+ sub_command = parsed_options['<command>']
40
+ sub_argv = parsed_options['<args>']
41
+
42
+ case sub_command
43
+ when 'build'
44
+ @sub_parser = Vanagon::CLI::Build.new
45
+ when 'build_host_info'
46
+ @sub_parser = Vanagon::CLI::BuildHostInfo.new
47
+ when 'build_requirements'
48
+ @sub_parser = Vanagon::CLI::BuildRequirements.new
49
+ when 'inspect'
50
+ @sub_parser = Vanagon::CLI::Inspect.new
51
+ when 'render'
52
+ @sub_parser = Vanagon::CLI::Render.new
53
+ when 'sign'
54
+ @sub_parser = Vanagon::CLI::Sign.new
55
+ when 'ship'
56
+ @sub_parser = Vanagon::CLI::Ship.new
57
+ when 'help'
58
+ puts DOCUMENTATION
59
+ exit 0
60
+ else
61
+ warn "vanagon: Error: unknown command: \"#{sub_command}\"\n\n#{DOCUMENTATION}"
62
+ exit 1
63
+ end
64
+
65
+ raw_options = @sub_parser.parse(sub_argv)
66
+ options = @sub_parser.options_translate(raw_options)
67
+ @sub_parser.options_validate(options)
68
+ return options
69
+ end
70
+
71
+ def run(options)
72
+ @sub_parser.run(options)
73
+ end
74
+
75
+ # Do validation of options
76
+ def options_validate(options)
77
+ options
78
+ end
79
+
80
+ # Provide a translation from parsed docopt options to older optparse options
81
+ def options_translate(docopt_options)
82
+ docopt_options
83
+ end
84
+
85
+ private
86
+
87
+ def parse_options(argv)
88
+ Docopt.docopt(DOCUMENTATION, { argv: argv, options_first: true })
89
+ rescue Docopt::Exit => e
90
+ puts e.message
91
+ exit 1
92
+ end
93
+ end
94
+ end