Skip to content

Commit

Permalink
chore: Move shell completion flag to cobrax library
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Nov 16, 2024
1 parent bd94d18 commit 6bf7dda
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 42 deletions.
4 changes: 0 additions & 4 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ func run(cmd *cobra.Command, args []string) error {
return err
}

if conf.Completion != "" {
return completion(cmd, conf.Completion)
}

slog.Info("Domain Watch", "version", cobrax.GetVersion(cmd), "commit", cobrax.GetCommit(cmd))

integrations, err := integration.Setup(cmd.Context(), conf)
Expand Down
25 changes: 0 additions & 25 deletions cmd/completion.go

This file was deleted.

2 changes: 1 addition & 1 deletion docs/domain-watch.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ domain-watch [flags] domain...
### Options

```
--completion string Output command-line completion code for the specified shell. Can be 'bash', 'zsh', 'fish', or 'powershell'.
--completion string Generate the autocompletion script for the specified shell (one of bash, zsh, fish, powershell)
--domains strings List of domains to watch
-e, --every duration Enable cron mode and configure update interval
--gotify-token string Gotify app token
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module gabe565.com/domain-watch
go 1.23.3

require (
gabe565.com/utils v0.0.0-20241114234101-e128cd3269b5
gabe565.com/utils v0.0.0-20241116061915-abe2278ecd5c
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/dmarkham/enumer v1.5.10
github.com/go-telegram/bot v1.10.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
gabe565.com/utils v0.0.0-20241114234101-e128cd3269b5 h1:uqtftvk1FMAsFPAT9ICLLntGsZHmrghgIGBClVCsVHk=
gabe565.com/utils v0.0.0-20241114234101-e128cd3269b5/go.mod h1:1WioSVukwGZYG4Q0LJBnRhgYyVljmW2Izl+RW36ALUc=
gabe565.com/utils v0.0.0-20241116061915-abe2278ecd5c h1:1rmGsS/Sbm85ZELLkfOtXJ99v3YHdmqvkhMDLteLUug=
gabe565.com/utils v0.0.0-20241116061915-abe2278ecd5c/go.mod h1:1WioSVukwGZYG4Q0LJBnRhgYyVljmW2Izl+RW36ALUc=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
4 changes: 0 additions & 4 deletions internal/config/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import (
)

func RegisterCompletions(cmd *cobra.Command) {
must.Must(cmd.RegisterFlagCompletionFunc(FlagCompletion, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{"bash", "zsh", "fish", "powershell"}, cobra.ShellCompDirectiveNoFileComp
}))

must.Must(cmd.RegisterFlagCompletionFunc(FlagDomains, cobra.NoFileCompletions))
must.Must(cmd.RegisterFlagCompletionFunc(FlagEvery, cobra.NoFileCompletions))
must.Must(cmd.RegisterFlagCompletionFunc(FlagSleep, cobra.NoFileCompletions))
Expand Down
2 changes: 0 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
)

type Config struct {
Completion string

Domains []string
Every time.Duration
Sleep time.Duration
Expand Down
6 changes: 3 additions & 3 deletions internal/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package config
import (
"strings"

"gabe565.com/utils/cobrax"
"gabe565.com/utils/must"
"github.com/spf13/cobra"
)

const (
FlagCompletion = "completion"

FlagDomains = "domains"
FlagEvery = "every"
FlagSleep = "sleep"
Expand All @@ -29,7 +29,7 @@ const (

func (c *Config) RegisterFlags(cmd *cobra.Command) {
fs := cmd.Flags()
fs.StringVar(&c.Completion, FlagCompletion, c.Completion, "Output command-line completion code for the specified shell. Can be 'bash', 'zsh', 'fish', or 'powershell'.")
must.Must(cobrax.RegisterCompletionFlag(cmd))

fs.StringSliceVar(&c.Domains, FlagDomains, c.Domains, "List of domains to watch")
fs.DurationVarP(&c.Every, FlagEvery, "e", c.Every, "Enable cron mode and configure update interval")
Expand Down

0 comments on commit 6bf7dda

Please sign in to comment.