[FIXED] bug where -d switch was passed to all commands.

This commit is contained in:
Sami Samhuri 2009-11-21 22:23:59 -08:00
parent 027a60f0f4
commit c75cbfe3b9
2 changed files with 34 additions and 14 deletions

View file

@ -1,6 +1,11 @@
CHANGELOG CHANGELOG
========= =========
sjs 2009-11-21
v 0.9.3 (one more bug fix for today)
- Don't pass -d switch to commands that don't accept it.
sjs 2009-11-21 sjs 2009-11-21
v 0.9.2 (bug fixes) v 0.9.2 (bug fixes)

43
mojo.el
View file

@ -1,5 +1,5 @@
;;; mojo.el --- Interactive functions to aid the development of webOS apps ;;; mojo.el --- Interactive functions to aid the development of webOS apps
;; 2009-11-21 19:23:18 ;; 2009-11-21 22:23:20
(defconst mojo-version "0.9.2") (defconst mojo-version "0.9.2")
(require 'json) (require 'json)
@ -118,6 +118,11 @@ ideas. Send me a pull request on github if you hack on mojo.el.")
;; ========= ;; =========
;; ;;
;; sjs 2009-11-21 ;; sjs 2009-11-21
;; v 0.9.3 (one more bug fix for today)
;;
;; - Don't pass -d switch to commands that don't accept it.
;;
;; sjs 2009-11-21
;; v 0.9.2 (bug fixes) ;; v 0.9.2 (bug fixes)
;; ;;
;; - reading json files no longer messes up your buffer history. ;; - reading json files no longer messes up your buffer history.
@ -244,39 +249,39 @@ NAME is the name of the scene."
(defun mojo-install () (defun mojo-install ()
"Install the package named by `MOJO-PACKAGE-FILENAME'. The emulator needs to be running." "Install the package named by `MOJO-PACKAGE-FILENAME'. The emulator needs to be running."
(interactive) (interactive)
(mojo-cmd "palm-install" (list (expand-file-name (mojo-read-package-filename)))) (mojo-cmd-with-target "palm-install" (list (expand-file-name (mojo-read-package-filename))))
(mojo-invalidate-app-cache)) (mojo-invalidate-app-cache))
;;* interactive ;;* interactive
(defun mojo-list () (defun mojo-list ()
"List all installed packages." "List all installed packages."
(interactive) (interactive)
(mojo-cmd "palm-install" (list "--list"))) (mojo-cmd-with-target "palm-install" (list "--list")))
;;* interactive ;;* interactive
(defun mojo-delete () (defun mojo-delete ()
"Remove the current application using `MOJO-APP-ID'." "Remove the current application using `MOJO-APP-ID'."
(interactive) (interactive)
(mojo-cmd "palm-install" (list "-r" (mojo-read-app-id))) (mojo-cmd-with-target "palm-install" (list "-r" (mojo-read-app-id)))
(mojo-invalidate-app-cache)) (mojo-invalidate-app-cache))
;;* interactive ;;* interactive
(defun mojo-launch () (defun mojo-launch ()
"Launch the current application in an emulator." "Launch the current application in an emulator."
(interactive) (interactive)
(mojo-cmd "palm-launch" (list (mojo-read-app-id)))) (mojo-cmd-with-target "palm-launch" (list (mojo-read-app-id))))
;;* interactive ;;* interactive
(defun mojo-close () (defun mojo-close ()
"Close launched application." "Close launched application."
(interactive) (interactive)
(mojo-cmd "palm-launch" (list "-c" (mojo-read-app-id)))) (mojo-cmd-with-target "palm-launch" (list "-c" (mojo-read-app-id))))
;;* launch interactive ;;* launch interactive
(defun mojo-inspect () (defun mojo-inspect ()
"Run the DOM inspector on the current application." "Run the DOM inspector on the current application."
(interactive) (interactive)
(mojo-cmd "palm-launch" (list "-i" (mojo-read-app-id)))) (mojo-cmd-with-target "palm-launch" (list "-i" (mojo-read-app-id))))
;;* emulator interactive ;;* emulator interactive
(defun mojo-hard-reset () (defun mojo-hard-reset ()
@ -294,16 +299,16 @@ NAME is the name of the scene."
"Package, install, and launch the current application for inspection." "Package, install, and launch the current application for inspection."
(interactive) (interactive)
(mojo-package) (mojo-package)
(mojo-cmd "palm-install" (list (expand-file-name (mojo-package-filename)))) (mojo-cmd-with-target "palm-install" (list (expand-file-name (mojo-package-filename))))
(mojo-cmd "palm-launch" (list "-i" (mojo-app-id)))) (mojo-cmd-with-target "palm-launch" (list "-i" (mojo-app-id))))
;;* interactive ;;* interactive
(defun mojo-package-install-and-launch () (defun mojo-package-install-and-launch ()
"Package, install, and launch the current application." "Package, install, and launch the current application."
(interactive) (interactive)
(mojo-package) (mojo-package)
(mojo-cmd "palm-install" (list (expand-file-name (mojo-package-filename)))) (mojo-cmd-with-target "palm-install" (list (expand-file-name (mojo-package-filename))))
(mojo-cmd "palm-launch" (list (mojo-app-id)))) (mojo-cmd-with-target "palm-launch" (list (mojo-app-id))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -543,7 +548,7 @@ Sets `*mojo-target*' to \"tcp\"."
(t (concat mojo-sdk-directory "/bin/" cmd)))) (t (concat mojo-sdk-directory "/bin/" cmd))))
;;* lowlevel cmd ;;* lowlevel cmd
(defun mojo-cmd (cmd args &optional target) (defun mojo-cmd (cmd args)
"General interface for running mojo-sdk commands. "General interface for running mojo-sdk commands.
CMD is the name of the command (without path or extension) to execute. CMD is the name of the command (without path or extension) to execute.
@ -551,11 +556,21 @@ CMD is the name of the command (without path or extension) to execute.
ARGS is a list of all arguments to the command. ARGS is a list of all arguments to the command.
These arguments are NOT shell quoted." These arguments are NOT shell quoted."
(let ((cmd (mojo-path-to-cmd cmd)) (let ((cmd (mojo-path-to-cmd cmd))
(args (concat "-d " (or target *mojo-target*) " " (args (string-join " " args)))
(string-join " " args))))
(if mojo-debug (message "running %s with args %s " cmd args)) (if mojo-debug (message "running %s with args %s " cmd args))
(shell-command (concat cmd " " args)))) (shell-command (concat cmd " " args))))
;;* lowlevel cmd
(defun mojo-cmd-with-target (cmd args &optional target)
"General interface for running mojo-sdk commands that accept a target device.
CMD is the name of the command (without path or extension) to
execute. Automagically shell quoted. ARGS is a list of all
arguments to the command. These arguments are NOT shell quoted.
TARGET specifies the target device, \"tcp\" or \"usb\"."
(let ((args (cons "-d" (cons (or target *mojo-target*) args))))
(mojo-cmd cmd args)))
;;* lowlevel cmd ;;* lowlevel cmd
(defun mojo-cmd-to-string (cmd args &optional target) (defun mojo-cmd-to-string (cmd args &optional target)
"General interface for running mojo-sdk commands and capturing the output "General interface for running mojo-sdk commands and capturing the output