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:
parent
0986b4e64f
commit
00eb093580
|
@ -1,3 +1,7 @@
|
||||||
|
== 0.1.1
|
||||||
|
|
||||||
|
* substantial improvements to the command line interface
|
||||||
|
|
||||||
== 0.1.0
|
== 0.1.0
|
||||||
|
|
||||||
* initial release
|
* initial release
|
||||||
|
|
|
@ -61,7 +61,7 @@ HTML
|
||||||
:verbose => false
|
:verbose => false
|
||||||
}
|
}
|
||||||
@argv = argv.clone
|
@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
|
self.options[:command] = @argv.shift
|
||||||
end
|
end
|
||||||
if @argv.first =~ /^[a-z0-9_-]+\.[a-z0-9_\.-]+$/i
|
if @argv.first =~ /^[a-z0-9_-]+\.[a-z0-9_\.-]+$/i
|
||||||
|
@ -85,7 +85,7 @@ HTML
|
||||||
opts.banner = "Usage: google-api " +
|
opts.banner = "Usage: google-api " +
|
||||||
"(execute <rpcname> | [command]) [options] [-- <parameters>]"
|
"(execute <rpcname> | [command]) [options] [-- <parameters>]"
|
||||||
|
|
||||||
opts.separator ""
|
opts.separator "\nAvailable options:"
|
||||||
|
|
||||||
opts.on(
|
opts.on(
|
||||||
"--scope <scope>", String, "Set the OAuth scope") do |s|
|
"--scope <scope>", String, "Set the OAuth scope") do |s|
|
||||||
|
@ -118,17 +118,25 @@ HTML
|
||||||
options[:content_type] = f
|
options[:content_type] = f
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on_tail("-v", "--verbose", "Run verbosely") do |v|
|
opts.on("-v", "--verbose", "Run verbosely") do |v|
|
||||||
options[:verbose] = v
|
options[:verbose] = v
|
||||||
end
|
end
|
||||||
opts.on_tail("-h", "--help", "Show this message") do
|
opts.on("-h", "--help", "Show this message") do
|
||||||
puts opts
|
puts opts
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
opts.on_tail("--version", "Show version") do
|
opts.on("--version", "Show version") do
|
||||||
puts "google-api-client (#{Google::APIClient::VERSION::STRING})"
|
puts "google-api-client (#{Google::APIClient::VERSION::STRING})"
|
||||||
exit
|
exit
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -283,9 +291,10 @@ HTML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def interactive
|
def irb
|
||||||
require 'signet/oauth_1/client'
|
require 'signet/oauth_1/client'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
require 'irb'
|
||||||
config_file = File.expand_path('~/.google-api.yaml')
|
config_file = File.expand_path('~/.google-api.yaml')
|
||||||
signed = File.exist?(config_file)
|
signed = File.exist?(config_file)
|
||||||
|
|
||||||
|
@ -314,7 +323,8 @@ HTML
|
||||||
config["token_credential_secret"]
|
config["token_credential_secret"]
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'irb'
|
# Otherwise IRB will misinterpret command-line options
|
||||||
|
ARGV.clear
|
||||||
IRB.start(__FILE__)
|
IRB.start(__FILE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -327,6 +337,11 @@ HTML
|
||||||
end
|
end
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def help
|
||||||
|
puts self.parser
|
||||||
|
exit(0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Google
|
||||||
module VERSION
|
module VERSION
|
||||||
MAJOR = 0
|
MAJOR = 0
|
||||||
MINOR = 1
|
MINOR = 1
|
||||||
TINY = 0
|
TINY = 1
|
||||||
|
|
||||||
STRING = [MAJOR, MINOR, TINY].join('.')
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue