Rename root, api and sdk module paths (imports, go.mod, go_package, ldflags, build scripts, buf configs) and regenerate protobuf/gateway code with the project's pinned toolchain. Wire identifiers unchanged. api gets a local replace for sdk; root/api/sdk require v0.1.0. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
71 lines
1.4 KiB
Go
71 lines
1.4 KiB
Go
// Copyright IBM Corp. 2020, 2026
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package cache
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/cmd/base"
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/errors"
|
|
"github.com/posener/complete"
|
|
)
|
|
|
|
type StopCommand struct {
|
|
*base.Command
|
|
}
|
|
|
|
func (c *StopCommand) Synopsis() string {
|
|
return "Stop the Threshold cache"
|
|
}
|
|
|
|
func (c *StopCommand) Help() string {
|
|
helpText := `
|
|
Usage: threshold cache stop
|
|
|
|
Stop a cache:
|
|
|
|
$ threshold cache stop
|
|
|
|
For a full list of examples, please see the documentation.
|
|
|
|
` + c.Flags().Help()
|
|
return strings.TrimSpace(helpText)
|
|
}
|
|
|
|
func (c *StopCommand) Flags() *base.FlagSets {
|
|
set := c.FlagSet(base.FlagSetNone)
|
|
return set
|
|
}
|
|
|
|
func (c *StopCommand) AutocompleteArgs() complete.Predictor {
|
|
return complete.PredictNothing
|
|
}
|
|
|
|
func (c *StopCommand) AutocompleteFlags() complete.Flags {
|
|
return c.Flags().Completions()
|
|
}
|
|
|
|
func (c *StopCommand) Run(args []string) int {
|
|
ctx, cancel := context.WithCancel(c.Context)
|
|
c.Context = ctx
|
|
c.ContextCancel = cancel
|
|
|
|
f := c.Flags()
|
|
if err := f.Parse(args); err != nil {
|
|
c.PrintCliError(err)
|
|
return base.CommandUserError
|
|
}
|
|
if err := c.stop(c.Context); err != nil {
|
|
if errors.Match(errors.T(errors.NotFound), err) {
|
|
c.PrintCliError(errCacheNotRunning)
|
|
} else {
|
|
c.PrintCliError(err)
|
|
}
|
|
return base.CommandUserError
|
|
}
|
|
|
|
return base.CommandSuccess
|
|
}
|