Add project files
This commit is contained in:
commit
f2fe6b8855
114 files changed
+20525
No files matched your search
@@ -0,0 +1,56 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <CLIForge/CLIForge.hpp>
|
||||
|
||||
#include "Commands.hpp"
|
||||
#include "breeze/Arguments.hpp"
|
||||
#include "breeze/Cli.hpp"
|
||||
#include "breeze/Error.hpp"
|
||||
#include "breeze/Project.hpp"
|
||||
#include "breeze/Tools.hpp"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::vector<std::string> given(argv + 1, argv + argc);
|
||||
|
||||
// Another CLI version may be the picked one: it takes over (never for `cli ...`).
|
||||
breeze::self::forwardToPicked(given);
|
||||
|
||||
// `breeze tool <id> ...` is the tool's own command line, which CLIForge knows nothing
|
||||
// about.
|
||||
if (given.size() >= 2 && given[0] == "tool" && given[1].rfind('-', 0) != 0 &&
|
||||
!breeze::tools::isReservedName(given[1]))
|
||||
{
|
||||
breeze::Project project = breeze::requireProject();
|
||||
std::optional<int> rc = breeze::tools::run(
|
||||
project, given[1], std::vector<std::string>(given.begin() + 2, given.end()));
|
||||
if (!rc)
|
||||
throw breeze::Error("there is no tool '" + given[1] +
|
||||
"' installed in this project (see `breeze tool ls`)");
|
||||
return *rc;
|
||||
}
|
||||
|
||||
cliforge::Engine engine("breeze");
|
||||
breeze::cli::registerCommands(engine);
|
||||
std::vector<std::string> args = breeze::cli::normalizeArguments(given);
|
||||
std::vector<char*> forwarded{argv[0]};
|
||||
for (std::string& a : args)
|
||||
forwarded.push_back(a.data());
|
||||
int rc = engine.run(static_cast<int>(forwarded.size()), forwarded.data());
|
||||
return rc != 0 ? rc : breeze::cli::exitCode();
|
||||
}
|
||||
catch (const breeze::Error& e)
|
||||
{
|
||||
std::cerr << "breeze: " << e.what() << "\n";
|
||||
return e.exitCode();
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << "breeze: unexpected error: " << e.what() << "\n";
|
||||
return 70;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user