diff --git a/CHANGELOG b/CHANGELOG index 6dd64ed7f..500028264 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +== 0.1.1 + +* substantial improvements to the command line interface + == 0.1.0 * initial release diff --git a/bin/google-api b/bin/google-api index 791f71825..26e4a3bd2 100755 --- a/bin/google-api +++ b/bin/google-api @@ -61,7 +61,7 @@ HTML :verbose => false } @argv = argv.clone - if @argv.first =~ /^[a-z0-9_-]+$/i + if @argv.first =~ /^[a-z0-9][a-z0-9_-]*$/i self.options[:command] = @argv.shift end if @argv.first =~ /^[a-z0-9_-]+\.[a-z0-9_\.-]+$/i @@ -85,7 +85,7 @@ HTML opts.banner = "Usage: google-api " + "(execute | [command]) [options] [-- ]" - opts.separator "" + opts.separator "\nAvailable options:" opts.on( "--scope ", String, "Set the OAuth scope") do |s| @@ -118,17 +118,25 @@ HTML options[:content_type] = f end - opts.on_tail("-v", "--verbose", "Run verbosely") do |v| + opts.on("-v", "--verbose", "Run verbosely") do |v| options[:verbose] = v end - opts.on_tail("-h", "--help", "Show this message") do + opts.on("-h", "--help", "Show this message") do puts opts exit end - opts.on_tail("--version", "Show version") do + opts.on("--version", "Show version") do puts "google-api-client (#{Google::APIClient::VERSION::STRING})" exit end + + opts.separator( + "\nAvailable commands:\n" + + " oauth-login Log a user into an API\n" + + " list List the methods available for a service\n" + + " execute Execute a method on the API\n" + + " irb Start an interactive client session" + ) end end @@ -283,9 +291,10 @@ HTML end end - def interactive + def irb require 'signet/oauth_1/client' require 'yaml' + require 'irb' config_file = File.expand_path('~/.google-api.yaml') signed = File.exist?(config_file) @@ -314,7 +323,8 @@ HTML config["token_credential_secret"] end - require 'irb' + # Otherwise IRB will misinterpret command-line options + ARGV.clear IRB.start(__FILE__) end @@ -327,6 +337,11 @@ HTML end exit(1) end + + def help + puts self.parser + exit(0) + end end end end diff --git a/lib/google/api_client/version.rb b/lib/google/api_client/version.rb index 4ee41de65..ef77290bc 100644 --- a/lib/google/api_client/version.rb +++ b/lib/google/api_client/version.rb @@ -17,7 +17,7 @@ module Google module VERSION MAJOR = 0 MINOR = 1 - TINY = 0 + TINY = 1 STRING = [MAJOR, MINOR, TINY].join('.') end