Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1688f6e

Browse files
authored
Merge pull request#286 from context-hub/feature/278
Add `--switch` flag to project:add command for automatic project switching
2 parents5eb201d +80fd67a commit1688f6e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎src/McpServer/Projects/Console/ProjectAddCommand.php‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ final class ProjectAddCommand extends BaseCommand
5151
)]
5252
protected ?string$envFile =null;
5353

54+
#[Option(
55+
name:'switch',
56+
shortcut:'s',
57+
description:'Switch to this project after adding it',
58+
)]
59+
protectedbool$switch =false;
60+
5461
publicfunction__invoke(
5562
Container$container,
5663
DirectoriesInterface$dirs,
@@ -132,6 +139,19 @@ public function __invoke(
132139
$projectService->setCurrentProject($projectPath,$this->name,$this->configFile,$this->envFile);
133140
$this->output->info('Project was automatically set as the current project (first project added).');
134141
}
142+
// If --switch flag is set for subsequent projects, switch to it
143+
elseif ($this->switch) {
144+
if ($projectService->switchToProject($projectPath)) {
145+
$this->output->info('Successfully switched to this project.');
146+
}else {
147+
$this->output->warning(
148+
\sprintf(
149+
"Project added but failed to switch. Use 'ctx project %s' to switch manually.",
150+
$this->name ??$projectPath,
151+
),
152+
);
153+
}
154+
}
135155

136156
return Command::SUCCESS;
137157
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp