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