Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BrewCmd = &cobra.Command{ Use: "brew", Short: "Update Homebrew packages only", Long: `This command updates only Homebrew packages, skipping system updates.`, Run: func(cmd *cobra.Command, args []string) { isVerbose := utils.IsVerbose(cmd) updateBrew(isVerbose) }, }
View Source
var FindNonMovieFoldersCmd = &cobra.Command{ Use: "findNonMovieFolders [directory]", Short: "Find and optionally delete non-movie folders", Long: `This command searches recursively through the supplied directory for directories that do not contain video files (mp4, mkv, avi, mov, wmv, flv, webm, mpeg, mpg, m4v). It identifies top-level subdirectories within the supplied directory that lack any such files anywhere within their structure. It can optionally delete these identified directories if the --dry-run flag is set to false. By default, --dry-run is true.`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { log.Start("Scanning for non-movie folders...") directory := args[0] isDryRun, _ := cmd.Flags().GetBool("dry-run") isVerbose := utils.IsVerbose(cmd) if _, err := os.Stat(directory); os.IsNotExist(err) { log.Error("Provided directory does not exist: %s", directory) return } log.Verbose(isVerbose, "Searching for directories in: %s", directory) log.Verbose(isVerbose, "Dry run mode: %t", isDryRun) spinner := utils.NewProgressSpinner("Scanning directories...") spinner.Start() defer spinner.Stop() nonMovieFolders, err := findNonMovieFolders(isVerbose, directory, func(done, total int) { progress := 0.0 if total > 0 { progress = float64(done) / float64(total) } spinner.SetProgressBar(progress, fmt.Sprintf("Scanning... (%d/%d)", done, total)) }) if err != nil { log.Error("Error finding non-movie folders: %s", err) return } spinner.UpdateMessage("Scan complete.") spinner.SetProgressBar(1.0) time.Sleep(200 * time.Millisecond) log.Verbose(isVerbose, "Found %d potential non-movie folders.", len(nonMovieFolders)) if len(nonMovieFolders) == 0 { log.Success("No non-movie folders found in %s.", directory) return } log.Message("Processing %d non-movie folder(s)...", len(nonMovieFolders)) deletedCount := 0 skippedCount := 0 for _, folder := range nonMovieFolders { listFilesCmd := exec.Command("find", folder, "-type", "f") filesToDeleteBytes, listErr := listFilesCmd.Output() if listErr != nil { log.Warn("Could not list files in folder %s (may be empty or permission issue): %s", folder, listErr) } filesList := strings.Split(strings.TrimSpace(string(filesToDeleteBytes)), "\n") actualFiles := []string{} if len(filesList) > 0 && filesList[0] != "" { actualFiles = filesList } if isVerbose && len(actualFiles) > 0 { log.Info("Files within %s:", folder) for _, file := range actualFiles { log.Info(" - %s", file) } } else if isVerbose { log.Info("Folder %s is empty or contains only empty subdirectories.", folder) } if isDryRun { log.Message("[Dry Run] Would delete folder: %s (%d files/items)", folder, len(actualFiles)) skippedCount++ } else { log.Warn("Deleting non-movie folder: %s (%d files/items)", folder, len(actualFiles)) deleteCmd := exec.Command("rm", "-rf", "--", folder) if err := deleteCmd.Run(); err != nil { log.Error("Error deleting folder %s: %s", folder, err) skippedCount++ } else { log.Success("Deleted: %s", folder) deletedCount++ } } } if isDryRun { log.Success("Dry run complete. %d folder(s) identified for deletion.", skippedCount) } else { log.Success("Processing complete. Deleted %d folder(s), skipped %d due to errors.", deletedCount, skippedCount) } }, }
View Source
var KillPortCmd = &cobra.Command{ Use: "killPort", Short: "Kill a supplied port", Long: `This will find what process is running on a supplied port, then kill that process.`, Run: func(cmd *cobra.Command, args []string) { if len(args) > 0 { KillString := fmt.Sprintf("kill -9 $(lsof -ti:%s)", strings.Join(args, ",")) log.Message("This should run: %s", KillString) killPortCmd := exec.Command(KillString) utils.StartChildProcess(killPortCmd) } else { log.Warn("You need to supply the port to kill, which will run the following:") } }, }
View Source
var ProxyCmd = &cobra.Command{ Use: "proxy", Short: "Show or configure system proxies", Long: `This command displays and manages multiple proxy configurations and allows enabling, disabling, or setting them via subcommands.`, Run: func(cmd *cobra.Command, args []string) { listProxyConfigurations() }, }
View Source
var SystemCmd = &cobra.Command{ Use: "system", Short: "A command for managing the system", Long: `This command will help manage various aspects of MacOS and Linux systems.`, Run: func(cmd *cobra.Command, args []string) { err := cmd.Help() cobra.CheckErr(err) }, }
View Source
var UpdateCmd = &cobra.Command{ Use: "update", Aliases: []string{"update", "u"}, Short: "Update the system", Long: `This command updates the system. It supports Ubuntu and WSL Linux systems and logs a message for unsupported systems.`, Run: func(cmd *cobra.Command, args []string) { isVerbose := utils.IsVerbose(cmd) log.Verbose(isVerbose, "Checking system type...") checkCmd := exec.Command("uname", "-a") output, err := checkCmd.Output() if err != nil { log.Error("Error checking system type: %s", err) return } uname := strings.ToLower(string(output)) log.Verbose(isVerbose, "System type detected: %s", strings.TrimSpace(string(output))) if strings.Contains(uname, "ubuntu") || strings.Contains(uname, "linux") { log.Verbose(isVerbose, "Detected Ubuntu/Linux system, running system update...") updateUbuntu(isVerbose) } else if strings.Contains(uname, "darwin") { log.Verbose(isVerbose, "Detected macOS system, running macOS update...") updateMacOS(isVerbose) } else if strings.Contains(uname, "raspberrypi") || strings.Contains(uname, "raspbian") { log.Verbose(isVerbose, "Detected Raspberry Pi system, running Raspberry Pi update...") updateRaspberryPi(isVerbose) } else { log.Warn("This system is not yet supported for updates.") log.Verbose(isVerbose, "Unsupported system type: %s", strings.TrimSpace(string(output))) } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.