Skip to content

Commit b123b9b

Browse files
committed
initial commit
0 parents  commit b123b9b

34 files changed

+1944
-0
lines changed

.gitignore

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Compiled app
2+
go-template
3+
4+
#########
5+
# macOS #
6+
#########
7+
8+
# General
9+
.DS_Store
10+
.AppleDouble
11+
.LSOverride
12+
13+
# Thumbnails
14+
._*
15+
16+
# Files that might appear in the root of a volume
17+
.DocumentRevisions-V100
18+
.fseventsd
19+
.Spotlight-V100
20+
.TemporaryItems
21+
.Trashes
22+
.VolumeIcon.icns
23+
.com.apple.timemachine.donotpresent
24+
25+
# Directories potentially created on remote AFP share
26+
.AppleDB
27+
.AppleDesktop
28+
Network Trash Folder
29+
Temporary Items
30+
.apdisk
31+
32+
33+
34+
35+
36+
######
37+
# Go #
38+
######
39+
40+
# If you prefer the allow list template instead of the deny list, see community template:
41+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
42+
#
43+
# Binaries for programs and plugins
44+
*.exe
45+
*.exe~
46+
*.dll
47+
*.so
48+
*.dylib
49+
50+
# Test binary, built with `go test -c`
51+
*.test
52+
53+
# Output of the go coverage tool, specifically when used with LiteIDE
54+
*.out
55+
56+
# Dependency directories (remove the comment below to include it)
57+
# vendor/
58+
59+
# Go workspace file
60+
go.work
61+
62+
###########
63+
# Windows #
64+
###########
65+
66+
# Windows thumbnail cache files
67+
Thumbs.db
68+
Thumbs.db:encryptable
69+
ehthumbs.db
70+
ehthumbs_vista.db
71+
72+
# Dump file
73+
*.stackdump
74+
75+
# Folder config file
76+
[Dd]esktop.ini
77+
78+
# Recycle Bin used on file shares
79+
$RECYCLE.BIN/
80+
81+
# Windows Installer files
82+
*.cab
83+
*.msi
84+
*.msix
85+
*.msm
86+
*.msp
87+
88+
# Windows shortcuts
89+
*.lnk
90+
91+
92+
93+
94+
95+
#########
96+
# Linux #
97+
#########
98+
99+
*~
100+
101+
# temporary files which can be created if a process still has a handle open of a deleted file
102+
.fuse_hidden*
103+
104+
# KDE directory preferences
105+
.directory
106+
107+
# Linux trash folder which might appear on any partition or disk
108+
.Trash-*
109+
110+
# .nfs files are created when an open file is removed but is still being accessed
111+
.nfs*
112+
113+
#############
114+
# JetBrains #
115+
#############
116+
117+
.idea

app/meta.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package app
2+
3+
// Version is the version of the application
4+
const Version = "0.0.2"
5+
6+
const (
7+
// App is the name of the application
8+
Name = "qufetch"
9+
10+
// DescriptionShort short description of the app
11+
DescriptionShort = Name + " a short tool to display system information"
12+
13+
// DescriptionLong long description of the app
14+
DescriptionLong = Name + " v" + Version
15+
)

cmd/clear.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"github.com/charmbracelet/lipgloss"
6+
7+
"github.com/anandMohanan/qufetch/app"
8+
"github.com/anandMohanan/qufetch/color"
9+
"github.com/anandMohanan/qufetch/filesystem"
10+
"github.com/anandMohanan/qufetch/icon"
11+
"github.com/anandMohanan/qufetch/util"
12+
"github.com/anandMohanan/qufetch/where"
13+
"github.com/samber/lo"
14+
"github.com/spf13/cobra"
15+
)
16+
17+
type clearTarget struct {
18+
name string
19+
clear func() error
20+
}
21+
22+
// Specify what can be cleared
23+
var clearTargets = []clearTarget{
24+
{"cache", func() error {
25+
return filesystem.Api().RemoveAll(where.Cache())
26+
}},
27+
{"logs", func() error {
28+
return filesystem.Api().RemoveAll(where.Logs())
29+
}},
30+
}
31+
32+
func init() {
33+
rootCmd.AddCommand(clearCmd)
34+
for _, n := range clearTargets {
35+
clearCmd.Flags().BoolP(n.name, string(n.name[0]), false, "clear "+n.name)
36+
}
37+
}
38+
39+
var clearCmd = &cobra.Command{
40+
Use: "clear",
41+
Short: "Clears sidelined files produced by the " + app.Name,
42+
Run: func(cmd *cobra.Command, args []string) {
43+
successStyle := lipgloss.NewStyle().Foreground(color.Green).Render
44+
var didSomething bool
45+
for _, n := range clearTargets {
46+
if lo.Must(cmd.Flags().GetBool(n.name)) {
47+
handleErr(n.clear())
48+
fmt.Printf("%s %s cleared\n", successStyle(icon.Check), util.Capitalize(n.name))
49+
didSomething = true
50+
}
51+
}
52+
53+
if !didSomething {
54+
_ = cmd.Help()
55+
}
56+
},
57+
}

0 commit comments

Comments
 (0)