docs: tighten mtm-ddwipe help and project guidance
This commit is contained in:
@@ -16,8 +16,9 @@ description: mtm-ddwipe project conventions
|
||||
- Keep the host and line-number removal behavior intact.
|
||||
- `mtm-ddwipe` must print a usage line and support `-h`/`--help`.
|
||||
- Validate that wipe targets are real block devices before operating on them.
|
||||
- Prefer explicit, short confirmation prompts before destructive operations.
|
||||
- Keep short, explicit confirmation prompts before destructive operations.
|
||||
- Keep error and help messages short, clear, and in English.
|
||||
- Keep help text concise and usage-first.
|
||||
|
||||
# Project identity
|
||||
- Main script: `mtm-ddwipe`
|
||||
|
||||
+24
-9
@@ -5,21 +5,35 @@ declare STARTDATE=""
|
||||
declare STARTDATESTRING=""
|
||||
|
||||
show_help() {
|
||||
echo "ddwipe dev (/dev/sdX)"
|
||||
echo "Usage: mtm-ddwipe DEVICE"
|
||||
echo ""
|
||||
echo "Version : 0.0.3"
|
||||
echo "Wipe a block device."
|
||||
echo "Version: 0.0.3"
|
||||
}
|
||||
|
||||
check_args() {
|
||||
if [ "${1}" == "" ]; then
|
||||
show_help
|
||||
exit 1
|
||||
fi
|
||||
case "${1}" in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
"")
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_dev_exist() {
|
||||
if [ ! -e "${1}" ]; then
|
||||
echo "${1} is missing."
|
||||
echo "Missing device."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_dev_block() {
|
||||
if [ ! -b "${1}" ]; then
|
||||
echo "Not a block device."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -27,7 +41,7 @@ check_dev_exist() {
|
||||
confirm_wipe() {
|
||||
lsblk "${1}"
|
||||
echo ""
|
||||
read -r -p "Wipe ${1} (y/[n])?" CHOICE
|
||||
read -r -p "Wipe ${1} (y/[n])? " CHOICE
|
||||
case "${CHOICE}" in
|
||||
y|Y ) echo "";;
|
||||
* )
|
||||
@@ -63,7 +77,7 @@ wipe_dev() {
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
echo "Device ${1} wipped !"
|
||||
echo "Device ${1} wiped."
|
||||
}
|
||||
|
||||
print_time() {
|
||||
@@ -84,6 +98,7 @@ print_time() {
|
||||
|
||||
check_args "${DEV}"
|
||||
check_dev_exist "${DEV}"
|
||||
check_dev_block "${DEV}"
|
||||
confirm_wipe "${DEV}"
|
||||
wipe_dev "${DEV}"
|
||||
print_time
|
||||
|
||||
Reference in New Issue
Block a user