Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
ArchiveAssemblyTool.cpp
Go to the documentation of this file.
1#include "ArchiveAssembly.hpp"
2
3#include <iostream>
4#include <stdexcept>
5#include <string_view>
6
7namespace
8{
9 void usage()
10 {
11 std::cout << "MonopolyArchiveTool --source <Source/monopoly> --output <workspace>\n"
12 " [--extra-root <directory>]... [--map <mapping.tsv>] [--strict]\n\n"
13 "TSV columns: bank<TAB>symbol<TAB>root<TAB>path\n"
14 "Root 0 is --source, other roots follow --extra-root order.\n"
15 "Reuses supplied disk payloads and converts compatible English.atr text.\n"
16 "No missing assets are fabricated. Partial banks remain isolated.\n"
17 "Exit 0: assembly/report produced (may be partial); 1: input/I/O error;\n"
18 " 2: CLI error; 3: --strict requested but a bank is incomplete.\n";
19 }
20}
21
22int main(int argc, char** argv)
23{
24 using namespace monopoly::data::assembly;
25 Request request;
26 for (int n=1;n<argc;++n)
27 {
28 const std::string_view key=argv[n];
29 if (key=="--help") { usage(); return 0; }
30 if (key=="--strict") { request.requireComplete=true; continue; }
31 if (key!="--source" && key!="--output" && key!="--extra-root" && key!="--map")
32 { std::cerr << "Unknown option: " << key << '\n'; usage(); return 2; }
33 if (++n==argc) { std::cerr << "Missing value for " << key << '\n'; return 2; }
34 const std::string_view value=argv[n];
35 const auto path=std::filesystem::path(std::u8string(value.begin(),value.end()));
36 if (key=="--source") request.sourceRoot=path;
37 else if (key=="--output") request.outputRoot=path;
38 else if (key=="--map") request.mappings=path;
39 else request.extraRoots.push_back(path);
40 }
41 if (request.sourceRoot.empty() || request.outputRoot.empty()) { usage(); return 2; }
42 try
43 {
44 const auto result=run(request);
45 return request.requireComplete && !result.complete() ? 3 : 0;
46 }
47 catch (const std::exception& error)
48 {
49 std::cerr << "Archive assembly failed: " << error.what() << '\n';
50 return 1;
51 }
52}
int main(int argc, char **argv)
std::uint64_t key
unsigned index
std::string path
std::string error
std::uint16_t value
Definition Timers.cpp:16
std::optional< std::filesystem::path > mappings
std::vector< std::filesystem::path > extraRoots