MCPcopy
hub / github.com/upstash/context7 / promptForSingleTarget

Function promptForSingleTarget

packages/cli/src/utils/ide.ts:192–257  ·  view source on GitHub ↗
(
  options: ListOptions | RemoveOptions
)

Source from the content-addressed store, hash-verified

190}
191
192export async function promptForSingleTarget(
193 options: ListOptions | RemoveOptions
194): Promise<{ ide: IDE; scope: Scope } | null> {
195 if (hasExplicitIdeOption(options)) {
196 const ides = getSelectedIdes(options);
197 const ide = ides[0] || DEFAULT_CONFIG.defaultIde;
198 const scope: Scope = options.global ? "global" : "project";
199 return { ide, scope };
200 }
201
202 log.blank();
203
204 const universalLabel = `Universal ${pc.dim(`(${UNIVERSAL_SKILLS_PATH})`)}`;
205 const choices: { name: string; value: IDE }[] = [
206 { name: `${IDE_NAMES["claude"]} ${pc.dim(`(${IDE_PATHS["claude"]})`)}`, value: "claude" },
207 { name: universalLabel, value: "universal" },
208 ];
209
210 for (const ide of VENDOR_SPECIFIC_AGENTS.filter((ide) => ide !== "claude")) {
211 choices.push({
212 name: `${IDE_NAMES[ide]} ${pc.dim(`(${IDE_PATHS[ide]})`)}`,
213 value: ide,
214 });
215 }
216
217 let selectedIde: IDE;
218 try {
219 selectedIde = await select({
220 message: "Which location?",
221 choices,
222 default: DEFAULT_CONFIG.defaultIde,
223 loop: false,
224 theme: { style: { highlight: (text: string) => pc.green(text) } },
225 });
226 } catch {
227 return null;
228 }
229
230 let selectedScope: Scope;
231 if (options.global !== undefined) {
232 selectedScope = options.global ? "global" : "project";
233 } else {
234 try {
235 selectedScope = await select({
236 message: "Which scope?",
237 choices: [
238 {
239 name: `Project ${pc.dim("(current directory)")}`,
240 value: "project" as Scope,
241 },
242 {
243 name: `Global ${pc.dim("(home directory)")}`,
244 value: "global" as Scope,
245 },
246 ],
247 default: DEFAULT_CONFIG.defaultScope,
248 loop: false,
249 theme: { style: { highlight: (text: string) => pc.green(text) } },

Callers 1

removeCommandFunction · 0.85

Calls 2

hasExplicitIdeOptionFunction · 0.85
getSelectedIdesFunction · 0.85

Tested by

no test coverage detected