MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / runList

Function runList

src/commands/project.ts:47–88  ·  view source on GitHub ↗
(
  opts: ListOptions,
  deps: ProjectDeps = {},
)

Source from the content-addressed store, hash-verified

45}
46
47export async function runList(
48 opts: ListOptions,
49 deps: ProjectDeps = {},
50): Promise<Page<CliProject>> {
51 const out = makeOutput(opts.output, deps);
52 const client = makeClient(opts, deps);
53
54 const paginationFlags: PaginationFlags = validatePaginationFlags({
55 pageSize: opts.pageSize,
56 startingToken: opts.startingToken,
57 maxItems: opts.maxItems,
58 });
59
60 // When the user explicitly passed a page-size flag and did NOT ask
61 // for --max-items, treat that as a "give me one page and the cursor"
62 // request — same shape AWS CLI ships. Otherwise auto-page.
63 const useSinglePage = opts.pageSize !== undefined && opts.maxItems === undefined;
64
65 let page: Page<CliProject>;
66 if (useSinglePage) {
67 page = await fetchSinglePage<CliProject>(
68 client,
69 '/projects',
70 paginationFlags.pageSize!,
71 opts.startingToken,
72 );
73 } else {
74 page = await paginate<CliProject>(
75 async ({ pageSize, cursor }) =>
76 client.get<Page<CliProject>>('/projects', {
77 query: { pageSize, cursor },
78 }),
79 paginationFlags,
80 );
81 }
82
83 out.print(page, data => {
84 const p = data as Page<CliProject>;
85 return renderProjectListText(p);
86 });
87 return page;
88}
89
90interface GetOptions extends CommonOptions {
91 projectId: string;

Callers 1

createProjectCommandFunction · 0.70

Calls 6

validatePaginationFlagsFunction · 0.85
renderProjectListTextFunction · 0.85
printMethod · 0.80
makeOutputFunction · 0.70
makeClientFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected