mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 15:45:06 +00:00
refactor: centralize subcommand help handlers
This commit is contained in:
10
bin/clean.sh
10
bin/clean.sh
@@ -1079,15 +1079,7 @@ main() {
|
|||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--help" | "-h")
|
"--help" | "-h")
|
||||||
echo "Usage: mo clean [OPTIONS]"
|
show_clean_help
|
||||||
echo ""
|
|
||||||
echo "Clean up disk space by removing caches, logs, and temporary files."
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " --dry-run, -n Preview cleanup without making changes"
|
|
||||||
echo " --whitelist Manage protected paths"
|
|
||||||
echo " --debug Show detailed operation logs"
|
|
||||||
echo " -h, --help Show this help message"
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--debug")
|
"--debug")
|
||||||
|
|||||||
@@ -669,13 +669,7 @@ main() {
|
|||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--help" | "-h")
|
"--help" | "-h")
|
||||||
echo "Usage: mo installer [OPTIONS]"
|
show_installer_help
|
||||||
echo ""
|
|
||||||
echo "Find and remove installer files (.dmg, .pkg, .iso, .xip, .zip)."
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " --debug Show detailed operation logs"
|
|
||||||
echo " -h, --help Show this help message"
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--debug")
|
"--debug")
|
||||||
|
|||||||
@@ -374,15 +374,7 @@ main() {
|
|||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--help" | "-h")
|
"--help" | "-h")
|
||||||
echo "Usage: mo optimize [OPTIONS]"
|
show_optimize_help
|
||||||
echo ""
|
|
||||||
echo "Check and maintain system health, apply optimizations."
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " --dry-run Preview optimization without making changes"
|
|
||||||
echo " --whitelist Manage protected items"
|
|
||||||
echo " --debug Show detailed operation logs"
|
|
||||||
echo " -h, --help Show this help message"
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--debug")
|
"--debug")
|
||||||
|
|||||||
@@ -307,20 +307,7 @@ main() {
|
|||||||
|
|
||||||
case "$command" in
|
case "$command" in
|
||||||
"--help" | "-h")
|
"--help" | "-h")
|
||||||
echo "Usage: mo touchid [COMMAND]"
|
show_touchid_help
|
||||||
echo ""
|
|
||||||
echo "Configure Touch ID for sudo authentication."
|
|
||||||
echo ""
|
|
||||||
echo "Commands:"
|
|
||||||
echo " enable Enable Touch ID for sudo"
|
|
||||||
echo " disable Disable Touch ID for sudo"
|
|
||||||
echo " status Show current Touch ID status"
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " -h, --help Show this help message"
|
|
||||||
echo ""
|
|
||||||
echo "If no command is provided, an interactive menu is shown."
|
|
||||||
exit 0
|
|
||||||
;;
|
;;
|
||||||
enable)
|
enable)
|
||||||
enable_touchid
|
enable_touchid
|
||||||
|
|||||||
@@ -758,13 +758,7 @@ main() {
|
|||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
"--help" | "-h")
|
"--help" | "-h")
|
||||||
echo "Usage: mo uninstall [OPTIONS]"
|
show_uninstall_help
|
||||||
echo ""
|
|
||||||
echo "Interactively remove applications and their leftover files."
|
|
||||||
echo ""
|
|
||||||
echo "Options:"
|
|
||||||
echo " --debug Show detailed operation logs"
|
|
||||||
echo " -h, --help Show this help message"
|
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--debug")
|
"--debug")
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ source "$_MOLE_CORE_DIR/log.sh"
|
|||||||
|
|
||||||
source "$_MOLE_CORE_DIR/timeout.sh"
|
source "$_MOLE_CORE_DIR/timeout.sh"
|
||||||
source "$_MOLE_CORE_DIR/file_ops.sh"
|
source "$_MOLE_CORE_DIR/file_ops.sh"
|
||||||
|
source "$_MOLE_CORE_DIR/help.sh"
|
||||||
source "$_MOLE_CORE_DIR/ui.sh"
|
source "$_MOLE_CORE_DIR/ui.sh"
|
||||||
source "$_MOLE_CORE_DIR/app_protection.sh"
|
source "$_MOLE_CORE_DIR/app_protection.sh"
|
||||||
|
|
||||||
|
|||||||
61
lib/core/help.sh
Normal file
61
lib/core/help.sh
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
show_clean_help() {
|
||||||
|
echo "Usage: mo clean [OPTIONS]"
|
||||||
|
echo ""
|
||||||
|
echo "Clean up disk space by removing caches, logs, and temporary files."
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --dry-run, -n Preview cleanup without making changes"
|
||||||
|
echo " --whitelist Manage protected paths"
|
||||||
|
echo " --debug Show detailed operation logs"
|
||||||
|
echo " -h, --help Show this help message"
|
||||||
|
}
|
||||||
|
|
||||||
|
show_installer_help() {
|
||||||
|
echo "Usage: mo installer [OPTIONS]"
|
||||||
|
echo ""
|
||||||
|
echo "Find and remove installer files (.dmg, .pkg, .iso, .xip, .zip)."
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --debug Show detailed operation logs"
|
||||||
|
echo " -h, --help Show this help message"
|
||||||
|
}
|
||||||
|
|
||||||
|
show_optimize_help() {
|
||||||
|
echo "Usage: mo optimize [OPTIONS]"
|
||||||
|
echo ""
|
||||||
|
echo "Check and maintain system health, apply optimizations."
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --dry-run Preview optimization without making changes"
|
||||||
|
echo " --whitelist Manage protected items"
|
||||||
|
echo " --debug Show detailed operation logs"
|
||||||
|
echo " -h, --help Show this help message"
|
||||||
|
}
|
||||||
|
|
||||||
|
show_touchid_help() {
|
||||||
|
echo "Usage: mo touchid [COMMAND]"
|
||||||
|
echo ""
|
||||||
|
echo "Configure Touch ID for sudo authentication."
|
||||||
|
echo ""
|
||||||
|
echo "Commands:"
|
||||||
|
echo " enable Enable Touch ID for sudo"
|
||||||
|
echo " disable Disable Touch ID for sudo"
|
||||||
|
echo " status Show current Touch ID status"
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " -h, --help Show this help message"
|
||||||
|
echo ""
|
||||||
|
echo "If no command is provided, an interactive menu is shown."
|
||||||
|
}
|
||||||
|
|
||||||
|
show_uninstall_help() {
|
||||||
|
echo "Usage: mo uninstall [OPTIONS]"
|
||||||
|
echo ""
|
||||||
|
echo "Interactively remove applications and their leftover files."
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --debug Show detailed operation logs"
|
||||||
|
echo " -h, --help Show this help message"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user