Significant improvements to the CLI.
git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@90 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef
This commit is contained in:
1 parent
0986b4e64f
commit
00eb093580
3 files changed
+27
-8
No files matched your search
+22
-7
@@ -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 <rpcname> | [command]) [options] [-- <parameters>]"
|
||||
|
||||
opts.separator ""
|
||||
opts.separator "\nAvailable options:"
|
||||
|
||||
opts.on(
|
||||
"--scope <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
|
||||
|
||||
Reference in new issue
Block a user