Skip to content

Instantly share code, notes, and snippets.

@kjkmr
Created October 11, 2010 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjkmr/621015 to your computer and use it in GitHub Desktop.
Save kjkmr/621015 to your computer and use it in GitHub Desktop.
#!/bin/bash
# forked from this -> http://www.libspark.org/browser/bash/flash
LOG_DIR="$HOME/Library/Preferences/Macromedia/Flash Player/Logs"
LOG_FILE="flashlog.txt"
LOG_PATH="${LOG_DIR}/${LOG_FILE}"
PLAYER_PATH="/Applications/Flash Player Debugger.app"
show_failure ()
{
echo -e "\033[31mError: $1\033[00m"
exit 1
}
show_warning ()
{
echo -e "\033[33mWarning: $1\033[00m"
}
usage ()
{
echo "usage: flash <option>"
echo "Available options:"
echo " shell (sh)"
echo " log"
echo " clear-log (cl)"
echo " (player) <swf file>"
echo " (debug) <as file>"
echo " help"
exit 0
}
if [ -z "$1" ]; then
usage
fi
case "$1" in
shell|sh)
cmd_fcsh=`which fcsh`
cmd_rlwrap=`which rlwrap`
if [ -z "${cmd_fcsh}" ]; then
show_failure "Can't find fcsh executable."
fi
if [ ! -z "${cmd_rlwrap}" ]; then
$cmd_rlwrap $cmd_fcsh
else
show_warning "Can't find rlwrap executable."
$cmd_fcsh
fi
;;
log)
$0 cl
tail -f "${LOG_PATH}"
;;
clear-log|cl)
if [ ! -d "${LOG_DIR}" ]; then
mkdir -p "${LOG_DIR}"
fi
echo '' > "${LOG_PATH}"
;;
player)
open -n -a "${PLAYER_PATH}" "$2"
;;
debug)
if mxmlc $2; then
config_path=`echo "$2" | sed -e "s/\.as$/-config.xml/"`
if [ -f "${config_path}" ]; then
swf_path=`grep "<output>" ${config_path} | sed -e "s/^.*<output>//" | sed -e "s/<\/output>.*$//"`
if [ ! -z `echo "$2" | grep "/"` ]; then
source_dir=`echo "$2" | sed -e "s/[^\/]*$//"`
cd "${source_dir}"
fi
$0 cl
tail -f "${LOG_PATH}" &
log_process=$!
trap 'kill "${log_process}"' 1 2 3 15
open -n -W -a "${PLAYER_PATH}" "${swf_path}"
kill "${log_process}"
else
show_failure "Can't find config file."
fi
fi
;;
*.swf)
$0 player $1
;;
*.as)
$0 debug $1
;;
help)
usage
;;
*)
show_failure "unknown argument"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment