Discovery is per user, so every project's launcher sees every debug app running, and with two of them up every command refused to guess and asked for -i, though the agent in one project meant its own app. Two copies of the example, both named basic, could only be told apart by id. The launcher now exports CRAFTER_DEBUG_PROJECT, its project's directory (flatpak-spawn gets it spelled out), and the client counts an app as the project's when its executable lies under it, as `-r` runs it from <project>/bin/<variant>/. With other projects' apps running, commands pick this project's; two copies of it still need -i. Another project's app is never picked by default: with this project's app not up yet, or crashed, the agent would otherwise drive, or quit, someone else's. It is listed instead, for -i. `ls` lists this project's apps first, marked, `--json` says which are, and `--wait` waits for one of them rather than any app; the exit code says whether one runs. A client started without the launcher has no project and picks the one app running, as before, and the command the protocol check prints for an older app's own client now names it with -i. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.4 KiB
C++
37 lines
1.4 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
// crafter-debug: Cli::Run with the QUIC transport.
|
|
import std;
|
|
import Crafter.Thread;
|
|
import Crafter.Debug.Core;
|
|
import Crafter.Debug.Cli;
|
|
using namespace Crafter::Debug;
|
|
|
|
int main(int argc, char** argv) {
|
|
// Crafter.Network reports some failures through the pool. One request
|
|
// at a time needs one worker.
|
|
Crafter::ThreadPool::Start(2);
|
|
const std::vector<std::string_view> args(argv + 1, argv + argc);
|
|
std::int32_t code = 0;
|
|
{
|
|
Cli::Environment environment;
|
|
environment.connect = Cli::ConnectQuic;
|
|
// Set by the project's launcher, build/crafter-debug.
|
|
if (const char* project = std::getenv("CRAFTER_DEBUG_PROJECT"); project != nullptr && *project != '\0') environment.project = project;
|
|
environment.lldb = [] {
|
|
for (const char* path : { "/app/bin/lldb", "/usr/bin/lldb" }) {
|
|
if (std::filesystem::exists(path)) return std::string(path);
|
|
}
|
|
return std::string();
|
|
};
|
|
// Run closes its connections before it returns.
|
|
code = Cli::Run(args, environment);
|
|
}
|
|
std::cout.flush();
|
|
std::cerr.flush();
|
|
std::fflush(nullptr);
|
|
// Not through exit: msquic's teardown at exit waits for connections,
|
|
// and the pool's workers would need stopping first.
|
|
std::_Exit(code);
|
|
}
|