From cdd6388acf603a9183f9e6af3b97ece734714c9a Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 2 Aug 2025 21:52:18 -0600 Subject: [PATCH] feat: implement unified dot command interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add modern `dot [subaction] [flags]` command structure to replace fragmented legacy commands. Provides intuitive, self-documenting CLI with comprehensive help system and error handling. New commands: - dot sync [status|on|off|--force] - dot packages [list|install|check|update|status|check-updates] - dot profile [show|set |detect] - dot reset [--soft|--hard|--nuclear] - dot help, dot version Features: - Colored output with clear error messages - Auto-sources required functions - Short aliases supported (e.g. 'pkg' for 'packages') - Removes all legacy dotcommand aliases for clean codebase 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- shared/aliases | 29 +------ shared/dot-command | 204 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 206 insertions(+), 27 deletions(-) create mode 100755 shared/dot-command diff --git a/shared/aliases b/shared/aliases index 343a40a..c0d27a2 100644 --- a/shared/aliases +++ b/shared/aliases @@ -61,33 +61,8 @@ alias myip='curl ifconfig.me' alias path='echo $PATH | tr ":" "\n"' alias reload='exec $SHELL' -# Dotfiles sync aliases -alias dotsync='dotfiles_sync_now' -alias dotsyncforce='dotfiles_sync_force' -alias dotstatus='dotfiles_sync_status' -alias dotson='dotfiles_sync_enable' -alias dotsoff='dotfiles_sync_disable' - -# Package management aliases -alias dotpkgs='dotfiles_packages_status' -alias dotinstall='dotfiles_install_packages' -alias dotcheck='dotfiles_check_packages' - -# Profile management aliases -alias dotprofile='dotfiles_profile_status' -alias dotprofileset='dotfiles_profile_set' -alias dotprofiledetect='dotfiles_profile_detect' - -# Reset aliases -alias dotreset='$HOME/.dotfiles/reset.sh' -alias dotresetsoft='$HOME/.dotfiles/reset.sh --soft' -alias dotresethard='$HOME/.dotfiles/reset.sh --hard' -alias dotresetnuke='$HOME/.dotfiles/reset.sh --nuclear' - -# Update aliases -alias dotupdatecheck='dotfiles_update_check' -alias dotupdatestatus='dotfiles_update_status' -alias dotupdate='dotfiles_update_install' +# Modern Dotfiles Management - Unified Command Interface +alias dot='$HOME/.dotfiles/shared/dot-command' # Task Master aliases alias tm='task-master' diff --git a/shared/dot-command b/shared/dot-command new file mode 100755 index 0000000..97c4cbb --- /dev/null +++ b/shared/dot-command @@ -0,0 +1,204 @@ +#!/bin/bash +# Modern Dotfiles Management System - Unified Command Interface +# Usage: dot [subaction] [flags] + +# Source required functions +DOTFILES_DIR="$HOME/.dotfiles" +if [[ -f "$DOTFILES_DIR/shared/functions" ]]; then + source "$DOTFILES_DIR/shared/functions" +fi +if [[ -f "$DOTFILES_DIR/shared/sync" ]]; then + source "$DOTFILES_DIR/shared/sync" +fi + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +# Function to print colored output +print_color() { + local color=$1 + local message=$2 + echo -e "${color}${message}${NC}" +} + +# Function to show help +show_help() { + print_color "$CYAN" "Modern Dotfiles Management System" + echo "" + print_color "$YELLOW" "Usage: dot [subaction] [flags]" + echo "" + print_color "$BLUE" "SYNC MANAGEMENT:" + echo " dot sync [--force] Sync dotfiles with remote repository" + echo " dot sync status Show sync status and last update" + echo " dot sync on Enable automatic syncing" + echo " dot sync off Disable automatic syncing" + echo "" + print_color "$BLUE" "PACKAGE MANAGEMENT:" + echo " dot packages [list] Show package status for current profile" + echo " dot packages install Install all packages for current profile" + echo " dot packages check Check package installation status" + echo " dot packages update Install pending updates" + echo " dot packages status Show update status" + echo " dot packages check-updates Check for package updates (fast)" + echo "" + print_color "$BLUE" "PROFILE MANAGEMENT:" + echo " dot profile [show] Show current machine profile" + echo " dot profile set Switch to specified profile" + echo " dot profile detect Re-detect machine type" + echo "" + print_color "$BLUE" "RESET OPERATIONS:" + echo " dot reset Interactive reset menu" + echo " dot reset --soft Remove configs, restore originals" + echo " dot reset --hard Soft reset + uninstall packages" + echo " dot reset --nuclear Complete removal (back to vanilla)" + echo "" + print_color "$BLUE" "GENERAL:" + echo " dot help Show this help message" + echo " dot version Show version information" + echo "" + print_color "$GREEN" "Examples:" + echo " dot sync --force Force sync now" + echo " dot profile set dev Switch to development profile" + echo " dot packages update Update all packages" + echo " dot reset --soft Safely reset configurations" +} + +# Function to show version +show_version() { + print_color "$CYAN" "Modern Dotfiles Management System" + print_color "$YELLOW" "Version: 2.0.0" + print_color "$GREEN" "Repository: https://git.turnersrus.com/razzam21/dotfiles" +} + +# Main command router +main() { + local action="$1" + local subaction="$2" + local flag="$3" + + case "$action" in + "sync") + case "$subaction" in + "status") + dotfiles_sync_status + ;; + "on") + dotfiles_sync_enable + ;; + "off") + dotfiles_sync_disable + ;; + "--force"|"force") + dotfiles_sync_force + ;; + "") + if [[ "$flag" == "--force" ]]; then + dotfiles_sync_force + else + dotfiles_sync_now + fi + ;; + *) + print_color "$RED" "Error: Unknown sync subaction '$subaction'" + echo "Use 'dot help' for available commands" + return 1 + ;; + esac + ;; + "packages"|"pkg") + case "$subaction" in + "list"|"") + dotfiles_packages_status + ;; + "install") + dotfiles_install_packages + ;; + "check") + dotfiles_check_packages + ;; + "update") + dotfiles_update_install + ;; + "status") + dotfiles_update_status + ;; + "check-updates") + dotfiles_update_check + ;; + *) + print_color "$RED" "Error: Unknown packages subaction '$subaction'" + echo "Use 'dot help' for available commands" + return 1 + ;; + esac + ;; + "profile") + case "$subaction" in + "show"|"") + dotfiles_profile_status + ;; + "set") + if [[ -z "$flag" ]]; then + print_color "$RED" "Error: Profile name required" + echo "Usage: dot profile set " + return 1 + fi + dotfiles_profile_set "$flag" + ;; + "detect") + dotfiles_profile_detect + ;; + *) + print_color "$RED" "Error: Unknown profile subaction '$subaction'" + echo "Use 'dot help' for available commands" + return 1 + ;; + esac + ;; + "reset") + case "$subaction" in + "--soft"|"soft") + "$HOME/.dotfiles/reset.sh" --soft + ;; + "--hard"|"hard") + "$HOME/.dotfiles/reset.sh" --hard + ;; + "--nuclear"|"nuclear") + "$HOME/.dotfiles/reset.sh" --nuclear + ;; + "") + "$HOME/.dotfiles/reset.sh" + ;; + *) + print_color "$RED" "Error: Unknown reset option '$subaction'" + echo "Available options: --soft, --hard, --nuclear" + return 1 + ;; + esac + ;; + "help"|"-h"|"--help") + show_help + ;; + "version"|"-v"|"--version") + show_version + ;; + "") + print_color "$RED" "Error: No action specified" + echo "Use 'dot help' for available commands" + return 1 + ;; + *) + print_color "$RED" "Error: Unknown action '$action'" + echo "Use 'dot help' for available commands" + return 1 + ;; + esac +} + +# Execute main function with all arguments +main "$@" \ No newline at end of file