cros-workon: change forall into iterate

* Bend iterate to accept either list of packages or --all, following the new
semantics

This is a re-upload of the original CL which seems to be broken beyond repair
by the git malfunctions yesterday

Review URL: http://codereview.chromium.org/3040001
This commit is contained in:
Zdenek Behan 2010-07-15 16:13:00 -07:00 committed by David James
parent 014939b2c7
commit d17540f6bc

View File

@ -27,12 +27,12 @@ DEFINE_string command "git status" \
DEFINE_boolean all "${FLAGS_FALSE}" \ DEFINE_boolean all "${FLAGS_FALSE}" \
"Apply to all possible packages for the given command" "Apply to all possible packages for the given command"
FLAGS_HELP="usage: $0 <command> [flags] FLAGS_HELP="usage: $0 <command> [flags] [<list of packages>|--all]
commands: commands:
start: Moves an ebuild to live (intended to support development) start: Moves an ebuild to live (intended to support development)
stop: Moves an ebuild to stable (use last known good) stop: Moves an ebuild to stable (use last known good)
list: List of live ebuilds (workon ebuilds if --all) list: List of live ebuilds (workon ebuilds if --all)
forall: For each ebuild, cd to the source dir and run a commond" iterate: For each ebuild, cd to the source dir and run a commond"
FLAGS "$@" || exit 1 FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}" eval set -- "${FLAGS_ARGV}"
@ -144,7 +144,7 @@ ebuild_to_stable () {
} }
# Run a command on all or a set of repos. # Run a command on all or a set of repos.
ebuild_forall() { ebuild_iterate() {
local atoms=$1 local atoms=$1
for atom in ${atoms}; do for atom in ${atoms}; do
@ -172,33 +172,23 @@ show_workon_ebuilds() {
if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then if [ ${FLAGS_all} = "${FLAGS_TRUE}" ]; then
case ${WORKON_CMD} in case ${WORKON_CMD} in
start) ATOM_LIST=$(show_workon_ebuilds);; start) ATOM_LIST=$(show_workon_ebuilds);;
stop) ATOM_LIST=$(show_live_ebuilds);; stop|iterate) ATOM_LIST=$(show_live_ebuilds);;
list) ;; list) ;;
*) die "--all is invalid for the given command";; *) die "--all is invalid for the given command";;
esac esac
else # not selected --all else # not selected --all
ATOM_LIST=$@ ATOM_LIST=$@
case ${WORKON_CMD} in if [ -z "${ATOM_LIST}" ]; then
start|stop) die "${WORKON_CMD}: No packages specified"
if [ -z "${ATOM_LIST}" ]; then elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then
die "${WORKON_CMD}: No packages specified" die "Error parsing package list"
elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then fi
die "Error parsing package list"
fi;;
forall)
if [ -z "${ATOM_LIST}" ]; then
ATOM_LIST=$(show_workon_ebuilds)
elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then
die "Error parsing package list"
fi;;
*) ;;
esac
fi fi
case ${WORKON_CMD} in case ${WORKON_CMD} in
start) ebuild_to_live "${ATOM_LIST}" ;; start) ebuild_to_live "${ATOM_LIST}" ;;
stop) ebuild_to_stable "${ATOM_LIST}" ;; stop) ebuild_to_stable "${ATOM_LIST}" ;;
list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;; list) [ ${FLAGS_all} = "${FLAGS_FALSE}" ] && show_live_ebuilds || show_workon_ebuilds ;;
forall) ebuild_forall "${ATOM_LIST}" ;; iterate) ebuild_iterate "${ATOM_LIST}" ;;
*) die "invalid cros_workon command" ;; *) die "invalid cros_workon command" ;;
esac esac