run method
Runs the command with parsed args.
Implementation
@override
Future<void> run(LocalCommandContext context, List<String> args) async {
final runFullScreen = context.runFullScreen;
if (runFullScreen == null) {
context.writeLine(':ide requires an interactive terminal.');
return;
}
if (args.length > 1) {
context.writeLine('usage: :ide [path]');
return;
}
final arg = args.isEmpty ? null : args.first;
// Connected → the remote node at its working directory; local → this machine.
final Workspace workspace;
if (context.client != null) {
final root = resolveRemoteIdeRoot(arg, context.currentRemoteCwd?.call());
if (root == null) {
context.writeLine(
':ide: remote working directory unknown yet — run a command first, '
'or pass an absolute path.',
);
return;
}
workspace = RemoteWorkspace(
client: context.requireClient,
nodeId: context.node.id.value,
rootPath: root,
shellFamily: context.shellFamily,
);
} else {
final root = resolveLocalIdeRoot(arg);
if (!Directory(root).existsSync()) {
context.writeLine(':ide: no such directory: $root');
return;
}
workspace = LocalWorkspace(root);
}
await runFullScreen(
(input) => runIdeApp(
workspace: workspace,
input: input,
shellFamily: context.shellFamily,
),
);
}