Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var FindNonMovieFoldersCmd = &cobra.Command{ Use: "findNonMovieFolders", 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. It can also delete these directories if the dry-run flag is not set.`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { log.Warn("You need to supply the directory to search for non-movie folders.") return } directory := args[0] dryRun, _ := cmd.Flags().GetBool("dry-run") verbose := utils.IsVerbose(cmd) if verbose { log.Verbose(verbose, "Searching for directories in: %s", directory) } findCmd := exec.Command("find", directory, "-type", "d") folders, err := findCmd.Output() if err != nil { log.Error("Error finding directories: %s", err) return } if verbose { log.Verbose(verbose, "Found directories: %s", strings.TrimSpace(string(folders))) } for _, folder := range strings.Split(string(folders), "\n") { if folder == "" { continue } if verbose { log.Verbose(verbose, "Checking folder: %s", folder) } checkCmd := exec.Command("find", folder, "-type", "f", "-iregex", ".*\\.(mp4|mkv|avi|mov|wmv|flv|webm|mpeg|mpg)") files, err := checkCmd.Output() if err != nil { log.Error("Error checking folder %s: %s", folder, err) continue } if verbose { log.Verbose(verbose, "Files found in folder %s: %s", folder, strings.TrimSpace(string(files))) } if strings.TrimSpace(string(files)) == "" { if dryRun { log.Message("Dry-run: Found non-movie folder: %s", folder) } else { log.Message("Deleting non-movie folder: %s", folder) deleteCmd := exec.Command("rm", "-rf", folder) if err := deleteCmd.Run(); err != nil { log.Error("Error deleting folder %s: %s", folder, err) } } } } }, }
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 the system proxy", Long: `This command displays the current system proxy and allows enabling or disabling it via flags or prompts.`, Run: func(cmd *cobra.Command, args []string) { proxy, enabled := config.ProxyConfig() fmt.Printf("Current proxy: %s\nEnabled: %v\n", proxy, enabled) }, }
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 UpdateSystemCmd = &cobra.Command{ Use: "updateSystem", Short: "Update the system", Long: `This command updates the system. It supports Ubuntu systems and logs a message for unsupported systems.`, Run: func(cmd *cobra.Command, args []string) { checkCmd := exec.Command("uname", "-a") output, err := checkCmd.Output() if err != nil { log.Error("Error checking system type: %s", err) return } if strings.Contains(strings.ToLower(string(output)), "ubuntu") { log.Message("Running system update for Ubuntu...") updateCmd := exec.Command("sudo", "apt", "update", "&&", "sudo", "apt", "upgrade", "-y") if err := updateCmd.Run(); err != nil { log.Error("Error updating system: %s", err) } else { log.Message("System updated successfully.") } } else { log.Message("This system is not yet supported for updates.") } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.