MCPcopy Create free account
hub / github.com/alibaba/open-code-review / completeSessionIDs

Function completeSessionIDs

cmd/opencodereview/session_cmd.go:177–199  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string, toComplete string)

Source from the content-addressed store, hash-verified

175}
176
177func completeSessionIDs(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
178 if len(args) != 0 {
179 return nil, cobra.ShellCompDirectiveNoFileComp
180 }
181 repo, _ := cmd.Flags().GetString("repo")
182 resolvedRepo, err := resolveWorkingDirForSession(repo)
183 if err != nil {
184 return nil, cobra.ShellCompDirectiveNoFileComp
185 }
186 summaries, err := session.ListSessions(resolvedRepo)
187 if err != nil {
188 return nil, cobra.ShellCompDirectiveNoFileComp
189 }
190 completions := make([]string, 0, len(summaries))
191 for _, s := range summaries {
192 if !strings.HasPrefix(s.SessionID, toComplete) {
193 continue
194 }
195 desc := fmt.Sprintf("%s · %d comments · %s", describeStart(s), s.TotalComments, describeStatus(s))
196 completions = append(completions, s.SessionID+"\t"+desc)
197 }
198 return completions, cobra.ShellCompDirectiveNoFileComp
199}
200
201func init() {
202 sessionListCmd.Flags().StringVar(&sessionListRepoDir, "repo", "", "root directory of the git repository (default: current dir)")

Callers 4

session_cmd.goFile · 0.85
TestCompleteSessionIDsFunction · 0.85

Calls 4

ListSessionsFunction · 0.92
describeStartFunction · 0.85
describeStatusFunction · 0.85

Tested by 2

TestCompleteSessionIDsFunction · 0.68