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

Function newSessionListCommand

internal/cli/session.go:152–195  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

150}
151
152func newSessionListCommand(deps commandDeps) *cobra.Command {
153 var (
154 includeAll bool
155 workspaceFilter string
156 resumable bool
157 limit int
158 )
159
160 cmd := &cobra.Command{
161 Use: sessionListKey,
162 Short: "List sessions",
163 Example: ` # List active sessions
164 agh session list
165
166 # Include stopped sessions and filter to a workspace
167 agh session list --all --workspace checkout-api`,
168 RunE: func(cmd *cobra.Command, _ []string) error {
169 client, err := clientFromDeps(deps)
170 if err != nil {
171 return err
172 }
173
174 sessions, err := client.ListSessions(cmd.Context(), SessionListQuery{
175 Workspace: workspaceFilter,
176 Resumable: resumable,
177 Limit: limit,
178 Sort: sessionListSortKey(resumable),
179 })
180 if err != nil {
181 return err
182 }
183 if !includeAll && !resumable {
184 sessions = filterActiveSessions(sessions)
185 }
186
187 return writeCommandOutput(cmd, sessionListBundle(sessions, deps.now))
188 },
189 }
190 cmd.Flags().BoolVar(&includeAll, "all", false, "Include stopped sessions")
191 cmd.Flags().StringVar(&workspaceFilter, workspaceSkillSource, "", "Filter by workspace name or ID")
192 cmd.Flags().BoolVar(&resumable, "resumable", false, "Show only sessions eligible for resume attach")
193 cmd.Flags().IntVar(&limit, "limit", 0, "Maximum sessions to return")
194 return cmd
195}
196
197func sessionListSortKey(resumable bool) string {
198 if resumable {

Callers 1

newSessionCommandFunction · 0.85

Calls 6

clientFromDepsFunction · 0.85
sessionListSortKeyFunction · 0.85
filterActiveSessionsFunction · 0.85
writeCommandOutputFunction · 0.85
sessionListBundleFunction · 0.85
ListSessionsMethod · 0.65

Tested by

no test coverage detected