Skip to content

Commit

Permalink
chore: update clean.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
harveyghq committed Jul 6, 2024
1 parent a71fbd5 commit f9e4234
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ The result is a JSON file containing feasible paths with their solutions, format
}
```

You can use `./clean.sh -f` to remove all files in the `output` folder.

## Example
To execute a program that takes no extra arguments or input, use the following command:

Expand Down
22 changes: 18 additions & 4 deletions clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ error() {

usage() {
cat >&2 <<END_USAGE
clean: remove output files and directories
clean.sh: remove and recreate empty "log" and "result" directories
USAGE:
clean [FLAGS]
clean.sh -[fi]
FLAGS:
-h, --help Prints help information
-i, --interactive Interactive mode
-f, --force Force remove output files and directories
END_USAGE
Expand All @@ -38,6 +39,19 @@ do
touch $OUTPUT_DIR/log/.placeholder $OUTPUT_DIR/result/.placeholder
exit 0
;;
-i|--interactive)
shift # shift off the argument
read -p "Are you sure you want to remove all output files and directories (rm -rf $OUTPUT_DIR)? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
rm -rf $OUTPUT_DIR
mkdir -p $OUTPUT_DIR/log $OUTPUT_DIR/result
touch $OUTPUT_DIR/log/.placeholder $OUTPUT_DIR/result/.placeholder
exit 0
fi
exit 1
;;
*)
error "Unknown option: '$arg'"
usage
Expand All @@ -46,5 +60,5 @@ do
esac
done

# normal delete
rm -ri $OUTPUT_DIR
usage
exit 1

0 comments on commit f9e4234

Please sign in to comment.