MCPcopy Create free account
hub / github.com/compozy/agh / newMemoryExtractorDrainCommand

Function newMemoryExtractorDrainCommand

internal/cli/memory.go:1056–1087  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

1054}
1055
1056func newMemoryExtractorDrainCommand(deps commandDeps) *cobra.Command {
1057 var timeoutRaw string
1058
1059 cmd := &cobra.Command{
1060 Use: memoryDrainKey,
1061 Short: "Drain Memory v2 extractor work",
1062 Args: cobra.NoArgs,
1063 RunE: func(cmd *cobra.Command, _ []string) error {
1064 client, err := clientFromDeps(deps)
1065 if err != nil {
1066 return err
1067 }
1068 timeout := 60 * time.Second
1069 if strings.TrimSpace(timeoutRaw) != "" {
1070 parsed, err := time.ParseDuration(strings.TrimSpace(timeoutRaw))
1071 if err != nil {
1072 return fmt.Errorf("memory.extractor.timeout_invalid: %w", err)
1073 }
1074 timeout = parsed
1075 }
1076 ctx, cancel := context.WithTimeout(cmd.Context(), timeout)
1077 defer cancel()
1078 response, err := client.DrainMemoryExtractor(ctx)
1079 if err != nil {
1080 return err
1081 }
1082 return writeCommandOutput(cmd, memoryObjectBundle("Memory Extractor Drain", response))
1083 },
1084 }
1085 cmd.Flags().StringVar(&timeoutRaw, "timeout", "60s", "Maximum drain wait duration")
1086 return cmd
1087}
1088
1089func newMemoryExtractorDisableCommand() *cobra.Command {
1090 var sessionID string

Callers 1

Calls 4

clientFromDepsFunction · 0.85
writeCommandOutputFunction · 0.85
memoryObjectBundleFunction · 0.85
DrainMemoryExtractorMethod · 0.65

Tested by

no test coverage detected