MCPcopy Create free account
hub / github.com/ding113/claude-code-hub / selectProviders

Method selectProviders

scripts/clear-session-bindings.ts:660–704  ·  view source on GitHub ↗
(providers: ProviderRecord[])

Source from the content-addressed store, hash-verified

658 }
659
660 async selectProviders(providers: ProviderRecord[]): Promise<ProviderRecord[]> {
661 this.displayProviderList(providers);
662
663 console.log("选择方式:");
664 console.log(" - 输入序号(逗号分隔): 1,2,3");
665 console.log(" - 输入范围: 1-5");
666 console.log(" - 输入 'all' 选择全部");
667 console.log(" - 输入 'q' 退出\n");
668
669 const input = await this.question("请选择要清理的供应商: ");
670
671 if (input.toLowerCase() === "q") {
672 return [];
673 }
674
675 if (input.toLowerCase() === "all") {
676 return providers;
677 }
678
679 const selectedIndices = new Set<number>();
680
681 // 解析输入
682 const parts = input.split(",").map((s) => s.trim());
683 for (const part of parts) {
684 if (part.includes("-")) {
685 const [start, end] = part.split("-").map((s) => Number.parseInt(s.trim(), 10));
686 if (!Number.isNaN(start) && !Number.isNaN(end)) {
687 for (let i = start; i <= end; i++) {
688 if (i >= 1 && i <= providers.length) {
689 selectedIndices.add(i - 1);
690 }
691 }
692 }
693 } else {
694 const index = Number.parseInt(part, 10);
695 if (!Number.isNaN(index) && index >= 1 && index <= providers.length) {
696 selectedIndices.add(index - 1);
697 }
698 }
699 }
700
701 return Array.from(selectedIndices)
702 .sort((a, b) => a - b)
703 .map((i) => providers[i]);
704 }
705
706 async confirm(message: string): Promise<boolean> {
707 const answer = await this.question(`${message} [y/N]: `);

Callers 1

mainFunction · 0.80

Calls 3

displayProviderListMethod · 0.95
questionMethod · 0.95
addMethod · 0.65

Tested by

no test coverage detected