bbcloud 0.11.2 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -2
- data/Gemfile +3 -0
- data/README +11 -1
- data/README.rdoc +11 -1
- data/Rakefile +12 -0
- data/bbcloud.gemspec +10 -10
- data/bin/brightbox-accounts +7 -2
- data/bin/brightbox-cloudips +7 -2
- data/bin/brightbox-config +7 -2
- data/bin/brightbox-images +7 -2
- data/bin/brightbox-lbs +7 -2
- data/bin/brightbox-servers +7 -2
- data/bin/brightbox-types +7 -2
- data/bin/brightbox-users +7 -2
- data/bin/brightbox-zones +7 -2
- data/lib/bbcloud.rb +43 -0
- data/lib/bbcloud/accounts.rb +5 -3
- data/lib/bbcloud/command_generator.rb +50 -0
- data/lib/bbcloud/commands/accounts-list.rb +13 -11
- data/lib/bbcloud/commands/accounts-reset-ftp-password.rb +26 -23
- data/lib/bbcloud/commands/accounts-show.rb +20 -16
- data/lib/bbcloud/commands/cloudips-create.rb +16 -14
- data/lib/bbcloud/commands/cloudips-destroy.rb +29 -26
- data/lib/bbcloud/commands/cloudips-list.rb +13 -11
- data/lib/bbcloud/commands/cloudips-map.rb +48 -46
- data/lib/bbcloud/commands/cloudips-show.rb +15 -12
- data/lib/bbcloud/commands/cloudips-unmap.rb +28 -25
- data/lib/bbcloud/commands/config-client-add.rb +33 -31
- data/lib/bbcloud/commands/config-client-default.rb +18 -16
- data/lib/bbcloud/commands/config-client-list.rb +19 -16
- data/lib/bbcloud/commands/config-client-remove.rb +18 -16
- data/lib/bbcloud/commands/images-destroy.rb +18 -16
- data/lib/bbcloud/commands/images-list.rb +20 -18
- data/lib/bbcloud/commands/images-register.rb +21 -19
- data/lib/bbcloud/commands/images-show.rb +17 -15
- data/lib/bbcloud/commands/lbs-add-nodes.rb +15 -13
- data/lib/bbcloud/commands/lbs-create.rb +65 -63
- data/lib/bbcloud/commands/lbs-destroy.rb +13 -11
- data/lib/bbcloud/commands/lbs-list.rb +13 -11
- data/lib/bbcloud/commands/lbs-remove-nodes.rb +15 -13
- data/lib/bbcloud/commands/lbs-show.rb +15 -13
- data/lib/bbcloud/commands/lbs-update.rb +59 -57
- data/lib/bbcloud/commands/servers-activate-cloud.rb +18 -16
- data/lib/bbcloud/commands/servers-create.rb +80 -77
- data/lib/bbcloud/commands/servers-destroy.rb +17 -15
- data/lib/bbcloud/commands/servers-list.rb +14 -14
- data/lib/bbcloud/commands/servers-show.rb +39 -37
- data/lib/bbcloud/commands/servers-shutdown.rb +14 -12
- data/lib/bbcloud/commands/servers-snapshot.rb +14 -12
- data/lib/bbcloud/commands/servers-start.rb +15 -13
- data/lib/bbcloud/commands/servers-stop.rb +14 -12
- data/lib/bbcloud/commands/types-list.rb +13 -11
- data/lib/bbcloud/commands/types-show.rb +18 -16
- data/lib/bbcloud/commands/users-list.rb +13 -11
- data/lib/bbcloud/commands/users-show.rb +17 -15
- data/lib/bbcloud/commands/users-update.rb +27 -25
- data/lib/bbcloud/commands/zones-list.rb +13 -11
- data/lib/bbcloud/config.rb +125 -111
- data/lib/bbcloud/error_parser.rb +34 -0
- data/lib/bbcloud/fog_extensions.rb +19 -0
- data/lib/bbcloud/gli_global_hooks.rb +56 -0
- data/lib/bbcloud/logging.rb +40 -0
- data/lib/bbcloud/ruby_core_ext.rb +9 -0
- data/lib/bbcloud/servers.rb +7 -2
- data/lib/bbcloud/tables.rb +78 -73
- data/lib/bbcloud/vendor/gli/.gitignore +10 -0
- data/lib/bbcloud/vendor/gli/.rvmrc +1 -0
- data/lib/bbcloud/vendor/gli/Gemfile +5 -0
- data/lib/bbcloud/vendor/gli/LICENSE.txt +201 -0
- data/lib/bbcloud/vendor/gli/README.rdoc +54 -0
- data/lib/bbcloud/vendor/gli/Rakefile +84 -0
- data/lib/bbcloud/vendor/gli/bin/gli +72 -0
- data/lib/bbcloud/vendor/gli/bin/report_on_rake_results +10 -0
- data/lib/bbcloud/vendor/gli/bin/test_all_rubies.sh +2 -0
- data/lib/bbcloud/vendor/gli/features/gli_executable.feature +88 -0
- data/lib/bbcloud/vendor/gli/features/gli_init.feature +122 -0
- data/lib/bbcloud/vendor/gli/features/step_definitions/gli_executable_steps.rb +12 -0
- data/lib/bbcloud/vendor/gli/features/step_definitions/gli_init_steps.rb +4 -0
- data/lib/bbcloud/vendor/gli/features/support/env.rb +21 -0
- data/lib/bbcloud/vendor/gli/gli.cheat +80 -0
- data/lib/bbcloud/vendor/gli/gli.gemspec +46 -0
- data/lib/bbcloud/vendor/gli/gli.rdoc +51 -0
- data/lib/bbcloud/vendor/gli/lib/gli.rb +560 -0
- data/lib/bbcloud/vendor/gli/lib/gli/command.rb +124 -0
- data/lib/bbcloud/vendor/gli/lib/gli/command_line_token.rb +58 -0
- data/lib/bbcloud/vendor/gli/lib/gli/copy_options_to_aliases.rb +33 -0
- data/lib/bbcloud/vendor/gli/lib/gli/exceptions.rb +45 -0
- data/lib/bbcloud/vendor/gli/lib/gli/flag.rb +67 -0
- data/lib/bbcloud/vendor/gli/lib/gli/options.rb +19 -0
- data/lib/bbcloud/vendor/gli/lib/gli/switch.rb +63 -0
- data/lib/bbcloud/vendor/gli/lib/gli/terminal.rb +79 -0
- data/lib/bbcloud/vendor/gli/lib/gli_version.rb +3 -0
- data/lib/bbcloud/vendor/gli/lib/support/help.rb +180 -0
- data/lib/bbcloud/vendor/gli/lib/support/initconfig.rb +34 -0
- data/lib/bbcloud/vendor/gli/lib/support/rdoc.rb +119 -0
- data/lib/bbcloud/vendor/gli/lib/support/scaffold.rb +284 -0
- data/lib/bbcloud/vendor/gli/test/config.yaml +9 -0
- data/lib/bbcloud/vendor/gli/test/gli.reek +116 -0
- data/lib/bbcloud/vendor/gli/test/roodi.yaml +9 -0
- data/lib/bbcloud/vendor/gli/test/tc_command.rb +329 -0
- data/lib/bbcloud/vendor/gli/test/tc_flag.rb +67 -0
- data/lib/bbcloud/vendor/gli/test/tc_gli.rb +429 -0
- data/lib/bbcloud/vendor/gli/test/tc_options.rb +31 -0
- data/lib/bbcloud/vendor/gli/test/tc_parsing.rb +279 -0
- data/lib/bbcloud/vendor/gli/test/tc_switch.rb +80 -0
- data/lib/bbcloud/vendor/gli/test/tc_terminal.rb +91 -0
- data/lib/bbcloud/version.rb +1 -1
- data/pkg/bbcloud-0.12.0.gem +0 -0
- data/spec/fixtures/vcr_cassettes/server_list.yml +117 -0
- data/spec/servers_spec.rb +36 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/common_helpers.rb +47 -0
- metadata +129 -135
- data/lib/bbcloud/cli.rb +0 -160
- data/lib/bbcloud/vendor/fog/lib/fog.rb +0 -14
- data/lib/bbcloud/vendor/fog/lib/fog/compute.rb +0 -43
- data/lib/bbcloud/vendor/fog/lib/fog/compute/brightbox.rb +0 -162
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/account.rb +0 -51
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/cloud_ip.rb +0 -47
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/cloud_ips.rb +0 -34
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/flavor.rb +0 -33
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/flavors.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/image.rb +0 -56
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/images.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/load_balancer.rb +0 -50
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/load_balancers.rb +0 -28
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/server.rb +0 -108
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/servers.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/user.rb +0 -39
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/users.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/zone.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/models/brightbox/zones.rb +0 -29
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/activate_console_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/add_listeners_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/add_nodes_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_api_client.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_cloud_ip.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_image.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_load_balancer.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/create_server.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_api_client.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_image.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/destroy_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_account.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_api_client.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_image.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_interface.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_server_type.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_user.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/get_zone.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_api_clients.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_cloud_ips.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_images.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_load_balancers.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_server_types.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_servers.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_users.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/list_zones.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/map_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/remove_listeners_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/remove_nodes_load_balancer.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/reset_ftp_password_account.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/resize_server.rb +0 -19
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/shutdown_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/snapshot_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/start_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/stop_server.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/unmap_cloud_ip.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_account.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_api_client.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_image.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_load_balancer.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_server.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/compute/requests/brightbox/update_user.rb +0 -21
- data/lib/bbcloud/vendor/fog/lib/fog/core.rb +0 -32
- data/lib/bbcloud/vendor/fog/lib/fog/core/attributes.rb +0 -178
- data/lib/bbcloud/vendor/fog/lib/fog/core/collection.rb +0 -127
- data/lib/bbcloud/vendor/fog/lib/fog/core/connection.rb +0 -35
- data/lib/bbcloud/vendor/fog/lib/fog/core/credentials.rb +0 -92
- data/lib/bbcloud/vendor/fog/lib/fog/core/deprecation.rb +0 -23
- data/lib/bbcloud/vendor/fog/lib/fog/core/errors.rb +0 -20
- data/lib/bbcloud/vendor/fog/lib/fog/core/hmac.rb +0 -48
- data/lib/bbcloud/vendor/fog/lib/fog/core/mock.rb +0 -68
- data/lib/bbcloud/vendor/fog/lib/fog/core/model.rb +0 -57
- data/lib/bbcloud/vendor/fog/lib/fog/core/parser.rb +0 -99
- data/lib/bbcloud/vendor/fog/lib/fog/core/provider.rb +0 -18
- data/lib/bbcloud/vendor/fog/lib/fog/core/scp.rb +0 -67
- data/lib/bbcloud/vendor/fog/lib/fog/core/service.rb +0 -175
- data/lib/bbcloud/vendor/fog/lib/fog/core/ssh.rb +0 -120
- data/lib/bbcloud/vendor/fog/lib/fog/core/time.rb +0 -27
- data/lib/bbcloud/vendor/fog/lib/fog/core/wait_for.rb +0 -17
- data/lib/bbcloud/vendor/fog/lib/fog/providers.rb +0 -9
- data/lib/bbcloud/vendor/fog/lib/fog/providers/brightbox.rb +0 -9
@@ -0,0 +1,54 @@
|
|
1
|
+
= Git-Like Interface Command Line Parser
|
2
|
+
|
3
|
+
Author:: Dave Copeland (mailto:davetron5000 at g mail dot com)
|
4
|
+
Copyright:: Copyright (c) 2010 by Dave Copeland
|
5
|
+
License:: Distributes under the Apache License, see LICENSE.txt in the source distro
|
6
|
+
|
7
|
+
This is a DSL you can use to create a command line interface like git, gem or svn, in that the first argument is a command, and there are global and command specific flags.
|
8
|
+
|
9
|
+
* {Source on Github}[http://github.com/davetron5000/gli]
|
10
|
+
* RDoc[http://davetron5000.github.com/gli]
|
11
|
+
|
12
|
+
== Use
|
13
|
+
|
14
|
+
Install if you need to:
|
15
|
+
|
16
|
+
gem install gli
|
17
|
+
|
18
|
+
The simplest way to get started is to create a scaffold project
|
19
|
+
|
20
|
+
gli init my_proj command_name other_command_name
|
21
|
+
|
22
|
+
This will create a basic scaffold project in <tt>./my_proj</tt> with:
|
23
|
+
|
24
|
+
* executable in <tt>./my_proj/bin/my_proj</tt>. This file demonstrates most of what you need to describe your command line interface.
|
25
|
+
* an empty test in <tt>./my_proj/test/tc_nothing.rb</tt> that can bootstrap your tests
|
26
|
+
* a gemspec shell
|
27
|
+
* a README shell
|
28
|
+
* Rakefile that can generate RDoc, package your Gem and run tests
|
29
|
+
* A <tt>Gemfile</tt> suitable for use with Bundler to manage development-time dependencies
|
30
|
+
|
31
|
+
== Supported Platforms
|
32
|
+
|
33
|
+
Known to work on
|
34
|
+
|
35
|
+
* 1.8.7
|
36
|
+
* 1.9.2
|
37
|
+
* Ruby Enterprise Edition 1.8.7
|
38
|
+
* Rubinius 1.0.1
|
39
|
+
* JRuby 1.5.2
|
40
|
+
|
41
|
+
If you're interested in other versions of Ruby, let me know, and I'll add them to my test suite
|
42
|
+
|
43
|
+
== Documentation
|
44
|
+
|
45
|
+
Extensive documentation is {available at the wiki}[https://github.com/davetron5000/gli/wiki]. For API Documentation, start with the GLI module.
|
46
|
+
|
47
|
+
== Links
|
48
|
+
|
49
|
+
* [http://davetron5000.github.com/gli] - RubyDoc
|
50
|
+
* [http://www.github.com/davetron5000/gli] - Source on GitHub
|
51
|
+
* [http://www.github.com/davetron5000/gli/wiki] - Documentation Wiki
|
52
|
+
* [http://www.github.com/davetron5000/gli/wiki/Changelog] - Changelog
|
53
|
+
|
54
|
+
:include:gli.rdoc
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/rdoctask'
|
6
|
+
require 'sdoc'
|
7
|
+
require 'grancher/task'
|
8
|
+
require 'reek/rake/task'
|
9
|
+
require 'roodi'
|
10
|
+
require 'roodi_task'
|
11
|
+
require 'cucumber'
|
12
|
+
require 'cucumber/rake/task'
|
13
|
+
|
14
|
+
CLEAN << "cruddo.rdoc"
|
15
|
+
CLEAN << "log"
|
16
|
+
CLOBBER << FileList['**/*.rbc']
|
17
|
+
|
18
|
+
Grancher::Task.new do |g|
|
19
|
+
g.branch = 'gh-pages'
|
20
|
+
g.push_to = 'origin'
|
21
|
+
g.directory 'html'
|
22
|
+
end
|
23
|
+
|
24
|
+
Rake::RDocTask.new do |rd|
|
25
|
+
rd.main = "README.rdoc"
|
26
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
27
|
+
rd.options << '--fmt' << 'shtml'
|
28
|
+
rd.template = 'direct'
|
29
|
+
rd.title = 'Git Like Interface'
|
30
|
+
end
|
31
|
+
|
32
|
+
spec = eval(File.read('gli.gemspec'))
|
33
|
+
|
34
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
35
|
+
end
|
36
|
+
|
37
|
+
Reek::Rake::Task.new do |t|
|
38
|
+
t.fail_on_error = true
|
39
|
+
t.config_files = ['test/gli.reek']
|
40
|
+
t.source_files = FileList['lib/**/*.rb'] - FileList['lib/support/*.rb']
|
41
|
+
end
|
42
|
+
|
43
|
+
RoodiTask.new do |t|
|
44
|
+
t.patterns = ['lib/*.rb','lib/gli/*.rb']
|
45
|
+
t.config = 'test/roodi.yaml'
|
46
|
+
end
|
47
|
+
|
48
|
+
Rake::TestTask.new do |t|
|
49
|
+
t.libs << "test"
|
50
|
+
t.test_files = FileList['test/tc_*.rb']
|
51
|
+
end
|
52
|
+
|
53
|
+
CUKE_RESULTS = 'results.html'
|
54
|
+
CLEAN << CUKE_RESULTS
|
55
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
56
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
|
57
|
+
t.fork = false
|
58
|
+
end
|
59
|
+
|
60
|
+
begin
|
61
|
+
require 'rcov/rcovtask'
|
62
|
+
task :clobber_coverage do
|
63
|
+
rm_rf "coverage"
|
64
|
+
end
|
65
|
+
|
66
|
+
desc 'Measures test coverage'
|
67
|
+
task :coverage => :rcov do
|
68
|
+
puts "coverage/index.html contains what you need"
|
69
|
+
end
|
70
|
+
|
71
|
+
Rcov::RcovTask.new do |t|
|
72
|
+
t.libs << 'lib'
|
73
|
+
t.test_files = FileList['test/tc_*.rb']
|
74
|
+
end
|
75
|
+
rescue LoadError
|
76
|
+
$stderr.puts "rcov not installed; you won't be able to check code coverage"
|
77
|
+
$stderr.puts "Since rcov only works on MRI 1.8.7, this shouldn't be a problem"
|
78
|
+
end
|
79
|
+
|
80
|
+
desc 'Publish rdoc on github pages and push to github'
|
81
|
+
task :publish_rdoc => [:rdoc,:publish]
|
82
|
+
|
83
|
+
task :default => [:test,:features,:roodi,:reek]
|
84
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# 1.9 adds realpath to resolve symlinks; 1.8 doesn't
|
3
|
+
# have this method, so we add it so we get resolved symlinks
|
4
|
+
# and compatibility
|
5
|
+
unless File.respond_to? :realpath
|
6
|
+
class File #:nodoc:
|
7
|
+
def self.realpath path
|
8
|
+
return realpath(File.readlink(path)) if symlink?(path)
|
9
|
+
path
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
15
|
+
|
16
|
+
require 'gli'
|
17
|
+
require 'support/scaffold'
|
18
|
+
require 'gli_version'
|
19
|
+
|
20
|
+
include GLI
|
21
|
+
|
22
|
+
program_desc 'gli allows you to create the scaffolding for a GLI-powered application'
|
23
|
+
|
24
|
+
version GLI::VERSION
|
25
|
+
desc 'Be verbose'
|
26
|
+
switch :v
|
27
|
+
|
28
|
+
desc 'Dry run; don''t change the disk'
|
29
|
+
switch :n
|
30
|
+
|
31
|
+
desc 'Root dir of project'
|
32
|
+
long_desc 'This is the directory where the project''s directory will be made, so if you specify a project name ''foo'' and the root dir of ''.'', the directory ''./foo'' will be created'
|
33
|
+
default_value '.'
|
34
|
+
flag [:r,:root]
|
35
|
+
|
36
|
+
desc 'Create a new GLI-based project'
|
37
|
+
long_desc <<EOS
|
38
|
+
This will create a scaffold command line project that uses GLI
|
39
|
+
for command line processing. Specifically, this will create
|
40
|
+
an executable ready to go, as well as a lib and test directory, all
|
41
|
+
inside the directory named for your project
|
42
|
+
EOS
|
43
|
+
arg_name 'project_name [command[ command]*]'
|
44
|
+
command [:init,:scaffold] do |c|
|
45
|
+
|
46
|
+
c.desc 'Create an ext dir'
|
47
|
+
c.switch [:e,:ext]
|
48
|
+
|
49
|
+
c.desc 'Do not create a test dir'
|
50
|
+
c.switch [:notest]
|
51
|
+
|
52
|
+
c.desc 'Overwrite/ignore existing files and directories'
|
53
|
+
c.switch [:force]
|
54
|
+
|
55
|
+
c.action do |g,o,args|
|
56
|
+
if args.length < 1
|
57
|
+
raise 'You must specify the name of your project'
|
58
|
+
end
|
59
|
+
Scaffold.create_scaffold(g[:r],!o[:notest],o[:e],args[0],args[1..-1],o[:force],g[:n])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
pre do |global,command,options,args|
|
64
|
+
puts "Executing #{command.name}" if global[:v]
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
post do |global,command,options,args|
|
69
|
+
puts "Executed #{command.name}" if global[:v]
|
70
|
+
end
|
71
|
+
|
72
|
+
exit run(ARGV)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'yaml'
|
3
|
+
require 'rainbow'
|
4
|
+
|
5
|
+
results = YAML::load(STDIN)
|
6
|
+
success = results["successes"] || []
|
7
|
+
errors = results["errors"] || []
|
8
|
+
success.each { |ruby| puts ruby.color(:green) }
|
9
|
+
errors.each { |ruby| puts ruby.color(:red) }
|
10
|
+
exit -1 unless errors.empty?
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Feature: The GLI executable works as intended
|
2
|
+
As a developer who wants to make a GLI-powered command-line app
|
3
|
+
When I use the app provided by GLI
|
4
|
+
I get a reasonably working application
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I have GLI installed
|
8
|
+
And my terminal size is "80x24"
|
9
|
+
|
10
|
+
Scenario Outline: Getting Help for GLI
|
11
|
+
When I run `gli <command>`
|
12
|
+
Then the exit status should be 0
|
13
|
+
And the output should contain:
|
14
|
+
"""
|
15
|
+
usage: gli [global options] command [command options]
|
16
|
+
|
17
|
+
Version:
|
18
|
+
"""
|
19
|
+
And the output should contain:
|
20
|
+
"""
|
21
|
+
Global Options:
|
22
|
+
-n - Dry run; dont change the disk
|
23
|
+
-r, --root=arg - Root dir of project (default: .)
|
24
|
+
-v - Be verbose
|
25
|
+
|
26
|
+
Commands:
|
27
|
+
help - Shows list of commands or help for one command
|
28
|
+
init, scaffold - Create a new GLI-based project
|
29
|
+
"""
|
30
|
+
|
31
|
+
Examples:
|
32
|
+
|command|
|
33
|
+
| |
|
34
|
+
|help |
|
35
|
+
|
36
|
+
|
37
|
+
Scenario Outline: Getting help on scaffolding
|
38
|
+
When I run `gli help <command>`
|
39
|
+
Then the exit status should be 0
|
40
|
+
And the output should contain exactly:
|
41
|
+
"""
|
42
|
+
init [command options] project_name [command[ command]*]
|
43
|
+
Create a new GLI-based project
|
44
|
+
|
45
|
+
This will create a scaffold command line project that uses GLI for command
|
46
|
+
line processing. Specifically, this will create an executable ready to go, as
|
47
|
+
well as a lib and test directory, all inside the directory named for your
|
48
|
+
project
|
49
|
+
|
50
|
+
Command Options:
|
51
|
+
-e, --ext - Create an ext dir
|
52
|
+
--force - Overwrite/ignore existing files and directories
|
53
|
+
--notest - Do not create a test dir
|
54
|
+
|
55
|
+
"""
|
56
|
+
|
57
|
+
Examples:
|
58
|
+
|command |
|
59
|
+
|init |
|
60
|
+
|scaffold |
|
61
|
+
|
62
|
+
|
63
|
+
Scenario: GLI correctly identifies non-existent command
|
64
|
+
When I run `gli foobar`
|
65
|
+
Then the exit status should not be 0
|
66
|
+
And the output should contain exactly:
|
67
|
+
"""
|
68
|
+
error: Unknown command 'foobar'. Use 'gli help' for a list of commands
|
69
|
+
|
70
|
+
"""
|
71
|
+
|
72
|
+
Scenario: GLI correctly identifies non-existent global flag
|
73
|
+
When I run `gli -q help`
|
74
|
+
Then the exit status should not be 0
|
75
|
+
And the output should contain exactly:
|
76
|
+
"""
|
77
|
+
error: Unknown option -q. Use 'gli help' for a list of global options
|
78
|
+
|
79
|
+
"""
|
80
|
+
|
81
|
+
Scenario: GLI correctly identifies non-existent command flag
|
82
|
+
When I run `gli init -q`
|
83
|
+
Then the exit status should not be 0
|
84
|
+
And the output should contain exactly:
|
85
|
+
"""
|
86
|
+
error: Unknown option -q. Use 'gli help init' for a list of command options
|
87
|
+
|
88
|
+
"""
|
@@ -0,0 +1,122 @@
|
|
1
|
+
Feature: The scaffold GLI generates works
|
2
|
+
As a developer who wants to make a GLI-powered command-line app
|
3
|
+
When I generate a GLI-powered app
|
4
|
+
Things work out of the box
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I have GLI installed
|
8
|
+
And GLI's libs are in my path
|
9
|
+
And my terminal size is "80x24"
|
10
|
+
|
11
|
+
Scenario: Scaffold generates and things look good
|
12
|
+
When I run `gli init todo add complete list`
|
13
|
+
Then the exit status should be 0
|
14
|
+
And the output should contain exactly:
|
15
|
+
"""
|
16
|
+
Creating dir ./todo/lib...
|
17
|
+
Creating dir ./todo/bin...
|
18
|
+
Creating dir ./todo/test...
|
19
|
+
Created ./todo/bin/todo
|
20
|
+
Created ./todo/README.rdoc
|
21
|
+
Created ./todo/todo.rdoc
|
22
|
+
Created ./todo/todo.gemspec
|
23
|
+
Created ./todo/test/tc_nothing.rb
|
24
|
+
Created ./todo/Rakefile
|
25
|
+
Created ./todo/Gemfile
|
26
|
+
Created ./todo/lib/todo_version.rb
|
27
|
+
|
28
|
+
"""
|
29
|
+
And the following directories should exist:
|
30
|
+
|todo |
|
31
|
+
|todo/bin |
|
32
|
+
|todo/test |
|
33
|
+
|todo/lib |
|
34
|
+
And the following files should exist:
|
35
|
+
|todo/bin/todo |
|
36
|
+
|todo/README.rdoc |
|
37
|
+
|todo/todo.rdoc |
|
38
|
+
|todo/todo.gemspec |
|
39
|
+
|todo/test/tc_nothing.rb |
|
40
|
+
|todo/Rakefile |
|
41
|
+
|todo/Gemfile |
|
42
|
+
|todo/lib/todo_version.rb |
|
43
|
+
When I cd to "todo"
|
44
|
+
And I run `bin/todo`
|
45
|
+
Then the output should contain:
|
46
|
+
"""
|
47
|
+
usage: todo [global options] command [command options]
|
48
|
+
|
49
|
+
Version: 0.0.1
|
50
|
+
|
51
|
+
Global Options:
|
52
|
+
-f, --flagname=The name of the argument - Describe some flag here (default:
|
53
|
+
the default)
|
54
|
+
-s, --switch - Describe some switch here
|
55
|
+
|
56
|
+
Commands:
|
57
|
+
add - Describe add here
|
58
|
+
complete - Describe complete here
|
59
|
+
help - Shows list of commands or help for one command
|
60
|
+
list - Describe list here
|
61
|
+
|
62
|
+
"""
|
63
|
+
When I run `bin/todo help add`
|
64
|
+
Then the output should contain:
|
65
|
+
"""
|
66
|
+
add [command options] Describe arguments to add here
|
67
|
+
Describe add here
|
68
|
+
|
69
|
+
Command Options:
|
70
|
+
-f arg - Describe a flag to add (default: default)
|
71
|
+
-s - Describe a switch to add
|
72
|
+
"""
|
73
|
+
When I run `rake test`
|
74
|
+
Then the output should contain:
|
75
|
+
"""
|
76
|
+
Started
|
77
|
+
.
|
78
|
+
"""
|
79
|
+
And the output should contain:
|
80
|
+
"""
|
81
|
+
|
82
|
+
1 tests, 1 assertions, 0 failures, 0 errors
|
83
|
+
"""
|
84
|
+
When I run `bin/todo rdoc`
|
85
|
+
Then the file "todo.rdoc" should contain "todo [global options] command_name [command-specific options] [--] arguments..."
|
86
|
+
And the file "todo.rdoc" should contain "[<tt>add</tt>] Describe add here"
|
87
|
+
And the file "todo.rdoc" should contain "[<tt>complete</tt>] Describe complete here"
|
88
|
+
And the file "todo.rdoc" should contain "[<tt>list</tt>] Describe list here"
|
89
|
+
|
90
|
+
@debug
|
91
|
+
Scenario: Scaffold generates and respects flags to create ext dir and avoid test dir
|
92
|
+
When I run `gli init -e --notest todo add complete list`
|
93
|
+
Then the exit status should be 0
|
94
|
+
And the output should contain exactly:
|
95
|
+
"""
|
96
|
+
Creating dir ./todo/lib...
|
97
|
+
Creating dir ./todo/bin...
|
98
|
+
Creating dir ./todo/ext...
|
99
|
+
Created ./todo/bin/todo
|
100
|
+
Created ./todo/README.rdoc
|
101
|
+
Created ./todo/todo.rdoc
|
102
|
+
Created ./todo/todo.gemspec
|
103
|
+
Created ./todo/Rakefile
|
104
|
+
Created ./todo/Gemfile
|
105
|
+
Created ./todo/lib/todo_version.rb
|
106
|
+
|
107
|
+
"""
|
108
|
+
And the following directories should exist:
|
109
|
+
|todo |
|
110
|
+
|todo/bin |
|
111
|
+
|todo/ext |
|
112
|
+
|todo/lib |
|
113
|
+
And the following directories should not exist:
|
114
|
+
|todo/test|
|
115
|
+
And the following files should exist:
|
116
|
+
|todo/bin/todo |
|
117
|
+
|todo/README.rdoc |
|
118
|
+
|todo/todo.rdoc |
|
119
|
+
|todo/todo.gemspec |
|
120
|
+
|todo/Rakefile |
|
121
|
+
|todo/Gemfile |
|
122
|
+
|todo/lib/todo_version.rb |
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Given /^I have GLI installed$/ do
|
2
|
+
end
|
3
|
+
|
4
|
+
Given /^my terminal size is "([^"]*)"$/ do |terminal_size|
|
5
|
+
if terminal_size =~/^(\d+)x(\d+)$/
|
6
|
+
ENV['COLUMNS'] = $1
|
7
|
+
ENV['LINES'] = $2
|
8
|
+
else
|
9
|
+
raise "Terminal size should be COLxLines, e.g. 80x24"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|