mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-07 23:03:11 +08:00
153 lines
3.5 KiB
Ruby
Executable File
153 lines
3.5 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
ROOT = File.expand_path(File.dirname(__FILE__).gsub('bin',''))
|
|
require 'fileutils'
|
|
require File.join(ROOT, "lib", "generate.rb")
|
|
require File.join(ROOT, "lib", "create.rb")
|
|
require File.join(ROOT, "lib", "run.rb")
|
|
require File.join(ROOT, "lib", "update.rb")
|
|
|
|
# ---------------------------------------------------------- #
|
|
# #
|
|
# command line interface #
|
|
# #
|
|
# ---------------------------------------------------------- #
|
|
|
|
# droidgap gen [app name]
|
|
Generate.new(ARGV[1]) if ARGV.first == 'gen'
|
|
|
|
# droidgap create [path to phonegap project]
|
|
Create.new(ARGV[1]) if ARGV.first == 'create'
|
|
|
|
# droidgap run [optional directory]
|
|
Run.new if ARGV.first == 'run'
|
|
|
|
# droidgap update [params]
|
|
Update.new if ARGV.first == 'update'
|
|
|
|
# droidgap log
|
|
if ARGV.first == 'log'
|
|
$stdout.sync = true
|
|
IO.popen('adb logcat') do |f|
|
|
until f.eof?
|
|
puts f.gets
|
|
end
|
|
end
|
|
end
|
|
|
|
# TODO implement these!
|
|
puts "droidgap ship not implemented" if ARGV.first == 'ship'
|
|
puts "droidgap test not implemented" if ARGV.first == 'test'
|
|
|
|
|
|
if ARGV.first.nil? || ARGV.first == 'help'
|
|
help = <<-EOF
|
|
|
|
DroidGap: PhoneGap/Android Dev Script
|
|
-------------------------------------
|
|
|
|
Useful utilities for devlopers building mobile apps using PhoneGap for Android.
|
|
|
|
Usage:
|
|
|
|
droidgap <command> <parameters>
|
|
|
|
Commands:
|
|
|
|
help ..... See this message. Type help <command name> to see specific help topics.
|
|
gen ...... Generate an example PhoneGap application to current directory.
|
|
create ... Creates an Android compatible project from a www folder. Careful, this clobbers previous packaging.
|
|
run ...... Installs a valid PhoneGap Project to first device found.
|
|
log ...... Attach a logger that listens for console.log statements.
|
|
update ... Copy a fresh phonegap.jar and phonegap.js into a valid PhoneGap/Android project.
|
|
test ..... Gets a copy of mobile-spec and runs in first device or emulator attached.
|
|
ship ..... Build and sign an APK suitable for submission to an Android Marketplace.
|
|
|
|
Quickstart:
|
|
|
|
$ droidgap gen example
|
|
$ cd example
|
|
$ droidgap run
|
|
|
|
Now you can launch your app and optionally start a logger with:
|
|
|
|
$ droidgap log
|
|
|
|
EOF
|
|
|
|
gen = <<-EOF
|
|
|
|
DroidGap Generate
|
|
-----------------
|
|
|
|
Generate an example PhoneGap application to path supplied or current working directory if none is supplied.
|
|
|
|
Usage:
|
|
|
|
droidgap gen [path]
|
|
|
|
EOF
|
|
|
|
run = <<-EOF
|
|
|
|
DroidGap Run
|
|
------------
|
|
|
|
Launches PhoneGap project to first device found and attaches a logger that listens for console.log statements.
|
|
|
|
Usage:
|
|
|
|
droidgap run <path>
|
|
|
|
EOF
|
|
|
|
ship = <<-EOF
|
|
|
|
DroidGap Ship
|
|
-------------
|
|
|
|
Build and sign an APK suitable for submission to an Android Marketplace.
|
|
|
|
Usage:
|
|
|
|
droidgap ship <path>
|
|
|
|
EOF
|
|
|
|
log = <<-EOF
|
|
|
|
DroidGap Log
|
|
-------------
|
|
|
|
Launches LogCat
|
|
|
|
Usage:
|
|
|
|
droidgap log
|
|
|
|
EOF
|
|
|
|
create = <<-EOF
|
|
|
|
DroidGap Create
|
|
----------------
|
|
|
|
Creates an Android compatable project from a PhoneGap project. For example, if you have MyProject with index.html this command will create MyProject-android.
|
|
|
|
Usage:
|
|
|
|
droidgap create <path>
|
|
|
|
EOF
|
|
|
|
update = <<-EOF
|
|
|
|
DroidGap Update
|
|
~~~~~~~~~~~~~~~
|
|
|
|
Builds the JS and PhoneGap Android jar file and copies them to your project.
|
|
|
|
EOF
|
|
|
|
puts ARGV[1].nil? ? help : eval(ARGV[1])
|
|
end
|