diff --git a/apollo.sh b/apollo.sh index 60a2cc684fbad3813daa3dd4c27b6edb34427a40..b40592771e3e39e96b2296b39e63e6be9061a9e8 100755 --- a/apollo.sh +++ b/apollo.sh @@ -121,7 +121,7 @@ function _usage() { ${BLUE}build_teleop${NO_COLOR}: run build with teleop enabled. ${BLUE}build_prof [module]${NO_COLOR}: build with perf profiling support. Not implemented yet. ${BLUE}doc${NO_COLOR}: generate doxygen document - ${BLUE}clean${NO_COLOR}: cleanup, including 'bazel clean --async'. + ${BLUE}clean${NO_COLOR}: cleanup bazel outputs and log/coredump files ${BLUE}usage${NO_COLOR}: show this message " } diff --git a/scripts/apollo_clean.sh b/scripts/apollo_clean.sh index 764b487ffe9f614fadbd35d3cfafd1d4dc1b5f2d..44a2eeb9092318c034dcf9276b9fe80d7a530931 100755 --- a/scripts/apollo_clean.sh +++ b/scripts/apollo_clean.sh @@ -26,16 +26,16 @@ LOG_DIR="${TOP_DIR}/data/log" function _clean_cache() { local opt="--async" - if [ "$1" == "expunge" ]; then + if [ "$1" == "--expunge" ]; then opt="--expunge_async" fi - bazel clean "${opt}" + bazel clean ${opt} # Remove bazel cache in associated directories if [ -d /apollo-simulator ]; then pushd /apollo-simulator > /dev/null - bazel clean "${opt}" + bazel clean ${opt} popd > /dev/null fi } @@ -64,9 +64,20 @@ function _clean_docs() { fi } -function clean() { +function _print_usage() { + echo -e "Usage:\n $0 [options]\nOptions:" + echo "${TAB}--expunge Run \"bazel clean --expunge\"" + echo "${TAB}-h, --help Show this message" +} + +function main() { + if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + _print_usage + exit 1 + fi + if ! "${APOLLO_IN_DOCKER}"; then - error "The clean operation must be run from within docker container" + error "The clean operation should be run from within docker container" exit 1 fi @@ -76,9 +87,10 @@ function clean() { local answer typeset -l answer - warning "All the files under ${LOG_DIR} and ${CORE_DIR} will be removed." - warning "Do you want to continue (Y/n)?" + warning "Do you want to remove all log files under \"${LOG_DIR}\"" \ + "and core dump files under \"${CORE_DIR}\" (Y/n)?" answer=$(read_one_char_from_stdin) + info "Your choice is: ${answer}" if [ "${answer}" == "y" ]; then _clean_core _clean_log @@ -87,8 +99,4 @@ function clean() { success "Apollo cleanup done." } -function main() { - clean "$@" -} - main "$@"