mirror of
https://github.com/0xERR0R/blocky.git
synced 2026-10-12 02:01:13 +00:00
- Update go.mod to Go 1.26.2 - Bump golangci-lint from v2.11.3 to v2.12.2 in Makefile - Rename gomodguard → gomodguard_v2 in .golangci.yml (v2 linter name) - Extract repeated string literals to constants to satisfy the stricter goconst checks introduced by the new linter version (19 issues fixed)
45 lines
815 B
Go
45 lines
815 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
const refreshCmdName = "refresh"
|
|
|
|
// NewListsCommand creates new command instance
|
|
func NewListsCommand() *cobra.Command {
|
|
c := &cobra.Command{
|
|
Use: "lists",
|
|
Short: "lists operations",
|
|
PersistentPreRunE: initConfigPreRun,
|
|
}
|
|
|
|
c.AddCommand(newRefreshCommand())
|
|
|
|
return c
|
|
}
|
|
|
|
func newRefreshCommand() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: refreshCmdName,
|
|
Short: "refreshes all lists",
|
|
RunE: refreshList,
|
|
}
|
|
}
|
|
|
|
func refreshList(cmd *cobra.Command, _ []string) error {
|
|
client, err := newAPIClient()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
resp, err := client.ListRefreshWithResponse(cmd.Context())
|
|
if err != nil {
|
|
return fmt.Errorf("can't execute %w", err)
|
|
}
|
|
|
|
return printOkOrError(resp, string(resp.Body))
|
|
}
|