Skip to content

Commit 29425bd

Browse files
committed
refactor: remove update feature from root command
- Remove import statements for &#34;os&#34; and &#34;os/exec&#34; in `root.go` - Remove `CheckForUpdate` function from `root.go` - Delete the `update.go` file, which includes the removal of the `updateCmd` command. Signed-off-by: Kai-Chu Chung <[email protected]>
1 parent cbe116c commit 29425bd

20 files changed

+0
-85
lines changed

cmd/binary.go

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func runBinary(cmd *cobra.Command, args []string) {
3030
}
3131
logrus.Debugf("query: %s", query)
3232

33-
CheckForUpdate()
34-
3533
_, err := strconv.ParseUint(query, 2, 64)
3634
if err != nil {
3735
wf.NewItem(fmt.Sprintf("`%s` is invalid binary", query)).Subtitle("Try a different query?").Icon(NumberGrayIcon)

cmd/case.go

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ func runCase(cmd *cobra.Command, args []string) {
6060
}
6161
logrus.Debugf("query: %s", query)
6262

63-
CheckForUpdate()
64-
6563
t, _ := cmd.Flags().GetString("type")
6664
if t == "command" {
6765
keys := make([]string, 0, len(M))

cmd/checksum.go

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ func runChecksum(cmd *cobra.Command, args []string) {
2929
}
3030
logrus.Debugf("query: %s", query)
3131

32-
CheckForUpdate()
33-
3432
s, err := lib.NewCheckSum(query)
3533
if err != nil {
3634
wf.NewItem(fmt.Sprintf("`%s` is invalid file", query)).Subtitle("Try a different query?").Icon(HashGrayIcon)

cmd/decimal.go

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ func runDecimal(cmd *cobra.Command, args []string) {
3131
}
3232
logrus.Debugf("query: %s", query)
3333

34-
CheckForUpdate()
35-
3634
c, err := strconv.ParseUint(query, 10, 64)
3735
if err != nil {
3836
wf.NewItem(fmt.Sprintf("`%s` is invalid decimal", query)).Subtitle("Try a different query?").Icon(NumberGrayIcon)

cmd/decode.go

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ func decodeRun(cmd *cobra.Command, args []string) {
2828
}
2929
logrus.Debugf("query: %s", query)
3030

31-
CheckForUpdate()
32-
3331
coder := lib.NewDecoder()
3432
b64DecodeStr := coder.Base64(query)
3533
wf.NewItem(b64DecodeStr).

cmd/encode.go

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ func encodeRun(cmd *cobra.Command, args []string) {
2828
}
2929
logrus.Debugf("query: %s", query)
3030

31-
CheckForUpdate()
32-
3331
coder := lib.NewEncoder()
3432
b64EncodeStr := coder.Base64(query)
3533
wf.NewItem(b64EncodeStr).

cmd/hash.go

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ func runHash(cmd *cobra.Command, args []string) {
2828
}
2929
logrus.Debugf("query: %s", query)
3030

31-
CheckForUpdate()
32-
3331
md5Str := lib.MD5(query)
3432
wf.NewItem(md5Str).
3533
Subtitle("⌘+L, ↩ Copy MD5").

cmd/hexadecimal.go

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func runHexadecimal(cmd *cobra.Command, args []string) {
3030
}
3131
logrus.Debugf("query: %s", query)
3232

33-
CheckForUpdate()
34-
3533
_, err := strconv.ParseUint(query, 16, 64)
3634
if err != nil {
3735
wf.NewItem(fmt.Sprintf("`%s` is invalid hexadecimal", query)).Subtitle("Try a different query?").Icon(NumberGrayIcon)

cmd/imageB64.go

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ func runImageB64(cmd *cobra.Command, args []string) {
4141
}
4242
logrus.Debugf("query: %s", query)
4343

44-
CheckForUpdate()
45-
4644
var err error
4745
if reUrl.Match([]byte(query)) {
4846
query, err = lib.Download(query, wf.DataDir())

cmd/json.go

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ func runJSON(cmd *cobra.Command, args []string) {
2929
}
3030
logrus.Debugf("query: %s", query)
3131

32-
CheckForUpdate()
33-
3432
j := lib.NewJSONFormat()
3533
if j.IsJSON(query) {
3634
wf.NewItem(query).

cmd/jwt.go

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func runJwt(c *cobra.Command, args []string) {
3030
}
3131
logrus.Debugf("query: %s", query)
3232

33-
CheckForUpdate()
34-
3533
token, err := lib.JWTdecode(query)
3634
if err == nil {
3735
a, _ := json.Marshal(token.Header)

cmd/loremipsum.go

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ func runLorem(cmd *cobra.Command, args []string) {
3535
}
3636
logrus.Debugf("query: %s", query)
3737

38-
CheckForUpdate()
39-
4038
c, err := strconv.ParseInt(query, 10, 64)
4139
if err != nil {
4240
wf.NewItem(fmt.Sprintf("`%s` is invalid integer", query)).Subtitle("Try a different query?").Icon(LoremIpsumGrayIcon)

cmd/nscommand.go

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ var nscommandCmd = &cobra.Command{
1616
}
1717

1818
func runNsCommand(cmd *cobra.Command, args []string) {
19-
CheckForUpdate()
2019

2120
wf.NewItem("Binary To ➜").Subtitle("↩ Launch Decimal, Octal, Hexadecimal").Valid(true).UID("1").Icon(NumberIcon).Var("type", "binary")
2221
wf.NewItem("Decimal To ➜").Subtitle("↩ Launch Binary, Octal, Hexadecimal").Valid(true).UID("2").Icon(NumberIcon).Var("type", "decimal")

cmd/octal.go

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ func runOctal(cmd *cobra.Command, args []string) {
3030
}
3131
logrus.Debugf("query: %s", query)
3232

33-
CheckForUpdate()
34-
3533
_, err := strconv.ParseUint(query, 8, 64)
3634
if err != nil {
3735
wf.NewItem(fmt.Sprintf("`%s` is invalid octal", query)).Subtitle("Try a different query?").Icon(NumberGrayIcon)

cmd/qrcode.go

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ func runQrcode(cmd *cobra.Command, args []string) {
6060
}
6161
logrus.Debugf("query: %s", query)
6262

63-
CheckForUpdate()
64-
6563
path := fmt.Sprintf("%s/qr.png", wf.DataDir())
6664
s, err := strconv.Atoi(alfred.GetQrcodeSize(wf))
6765
if err != nil {

cmd/root.go

-24
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
/*
22
Copyright © 2022 KAI CHU CHUNG <[email protected]>
3-
43
*/
54
package cmd
65

76
import (
8-
"os"
9-
"os/exec"
10-
117
aw "github.com/deanishe/awgo"
128
"github.com/deanishe/awgo/update"
139
"github.com/sirupsen/logrus"
@@ -23,31 +19,11 @@ var (
2319
wf *aw.Workflow
2420
)
2521

26-
func CheckForUpdate() {
27-
if wf.UpdateCheckDue() && !wf.IsRunning(updateJobName) {
28-
logrus.Info("Running update check in background...")
29-
cmd := exec.Command(os.Args[0], "update")
30-
if err := wf.RunInBackground(updateJobName, cmd); err != nil {
31-
logrus.Errorf("Error starting update check: %s", err)
32-
}
33-
}
34-
35-
if wf.UpdateAvailable() {
36-
wf.Configure(aw.SuppressUIDs(true))
37-
wf.NewItem("An update is available!").
38-
Subtitle("⇥ or ↩ to install update").
39-
Valid(false).
40-
Autocomplete("workflow:update").
41-
Icon(&aw.Icon{Value: "download.pdf"})
42-
}
43-
}
44-
4522
// rootCmd represents the base command when called without any subcommands
4623
var rootCmd = &cobra.Command{
4724
Use: "alfred-devtoys",
4825
Short: "A Swiss Army knife for developers for Alfred",
4926
Run: func(cmd *cobra.Command, args []string) {
50-
CheckForUpdate()
5127
wf.SendFeedback()
5228
},
5329
}

cmd/time.go

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ type TimeFormatItem struct {
3333
}
3434

3535
func runTimeCmd(cmd *cobra.Command, args []string) {
36-
CheckForUpdate()
3736

3837
var query int64
3938
var err error

cmd/timeCopy.go

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var timeCopyCmd = &cobra.Command{
2323
}
2424

2525
func runTimeCopyCmd(cmd *cobra.Command, args []string) {
26-
CheckForUpdate()
2726

2827
prefFile := path.Join(wf.Dir(), "info.plist")
2928
if dpf := os.Getenv("DEBUG_PLIST_FOLDER"); dpf != "" {

cmd/update.go

-28
This file was deleted.

cmd/uuid.go

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ func runUuid(cmd *cobra.Command, args []string) {
3535
}
3636
logrus.Debugf("query: %s", query)
3737

38-
CheckForUpdate()
39-
4038
c, err := strconv.ParseInt(query, 10, 64)
4139
if err != nil {
4240
wf.NewItem(fmt.Sprintf("`%s` is invalid integer", query)).Subtitle("Try a different query?").Icon(UuidGrayIcon)

0 commit comments

Comments
 (0)