diff --git a/README.md b/README.md index 6ef3f1c..4023ee3 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ The goal is to provide disk cleaning functionality like BleachBit, but in a zero `topclean` is intended to be executed when you are running low on disk space and you are sure that deleting temporary files, caches, files marked for deletion (e.g. recycle bin) etc. is safe. -Until builds are provided, you need to run `go run main.go`. +Until builds are provided, you need to run `go run topclean.go`. ## Licence -[MIT](LICENCE.md) \ No newline at end of file +[MIT](LICENCE) \ No newline at end of file diff --git a/main.go b/topclean.go similarity index 62% rename from main.go rename to topclean.go index a80d123..aa1af15 100644 --- a/main.go +++ b/topclean.go @@ -6,15 +6,22 @@ import ( "os/exec" ) +var prefix = "[topclean] " +var apps = []App{ + {"scoop", "scoop", []string{"cleanup", "*"}}, + {"npm", "npm", []string{"cache", "clean", "--force"}}, + {"yarn", "yarn", []string{"cache", "clean"}}, + {"cleanmgr", "cleanmgr", []string{"/d", "c", "/verylowdisk"}}, +} + func main() { - fmt.Print("topclean\n\n") - apps := getApps() + fmt.Println(prefix + "Starting!") for i := 0; i < len(apps); i++ { app := apps[i] err := clean(app) catch(err) } - fmt.Print("\ndone\n") + fmt.Println(prefix + "Done!") } type App struct { @@ -23,24 +30,13 @@ type App struct { args []string } -func getApps() []App { - apps := []App{ - {"scoop", "scoop", []string{"cleanup", "*"}}, - {"npm", "npm", []string{"cache", "clean", "--force"}}, - {"yarn", "yarn", []string{"cache", "clean"}}, - {"cleanmgr", "cleanmgr", []string{"/d", "c", "/verylowdisk"}}, - } - return apps -} - func clean(app App) error { - fmt.Println("Cleaning " + app.name) + fmt.Println(prefix + "Cleaning " + app.name) var stdout, stderr bytes.Buffer cmd := exec.Command(app.cmd, app.args...) cmd.Stdout = &stdout cmd.Stderr = &stderr err := cmd.Run() - catch(err) cmdLog(stdout.String(), stderr.String()) return err }