Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use standard ruby optparser banner for help. Move option parsing ahea…

…d of asking for the first arguement.
  • Loading branch information...
commit f5118d0ca94ad44648cf2eb9fb8066d3e3d5a517 1 parent 491400e
@btatnall btatnall authored
Showing with 38 additions and 40 deletions.
  1. +38 −15 bin/hubbard
  2. +0 −25 commands/help.rb
View
53 bin/hubbard
@@ -9,6 +9,44 @@ require 'hubbard'
FileUtils.mkdir_p(Hubbard::PROJECTS_PATH)
FileUtils.mkdir_p(Hubbard::ACCOUNTS_PATH)
+formats = [:text, :yaml]
+defaults = { :format => formats.first }
+options = {}
+OptionParser.new do |opts|
+ opts.banner = <<BANNER
+Usage: hubbard [options] <command>
+
+Projects:
+list-projects
+create-project <project>
+delete-project <project>
+
+Repositories:
+list-repositories <project>
+create-repository <project> <repository>
+delete-repository <project> <repository>
+fork-repository <from-project> <from-repository> <to-project> <to-repository>
+list-forks <project> <repository>
+
+Permissions:
+list-permissions <project>
+add-permission <project> <username> read|write|admin
+remove-permission <project> <username>
+
+Options:
+BANNER
+
+ opts.on("--private", "Create project with visibility set to private") do |o|
+ options[:private] = o
+ end
+ opts.on("-f", "--format [FORMAT]", formats,
+ "Output format (#{formats.join(', ')})") do |o|
+ options[:format] = o
+ end
+end.parse!
+OPTIONS = defaults.merge(options)
+OPTIONS.freeze
+
def next_arg(msg)
if ARGV.length < 1
$stderr.puts msg
@@ -61,21 +99,6 @@ if ENV['SSH_ORIGINAL_COMMAND']
end
end
-formats = [:text, :yaml]
-defaults = { :format => formats.first }
-options = {}
-OptionParser.new do |opts|
- opts.on("--private", "Create project with visibility set to private") do |o|
- options[:private] = o
- end
- opts.on("-f", "--format [FORMAT]", formats,
- "Select format (#{formats.join(', ')})") do |o|
- options[:format] = o
- end
-end.parse!
-OPTIONS = defaults.merge(options)
-OPTIONS.freeze
-
command = next_arg "Please specify a command to run"
if command == "run-as"
View
25 commands/help.rb
@@ -1,25 +0,0 @@
-$stderr.puts <<-END
-Usage: hub <command>
-
-Projects:
-
-list-projects
-create-project <project>
-delete-project <project>
-
-Repositories:
-
-list-repositories <project>
-create-repository <project> <repository>
-delete-repository <project> <repository>
-fork-repository <from-project> <from-repository> <to-project> <to-repository>
-list-forks <project> <repository>
-
-Permissions:
-
-list-permissions <project>
-add-permission <project> <username> read|write|admin
-remove-permission <project> <username>
-
-END
-exit 0
Please sign in to comment.
Something went wrong with that request. Please try again.