57 lines
No EOL
1.1 KiB
C++
57 lines
No EOL
1.1 KiB
C++
|
|
#include <Spectre/System/File.h>
|
|
#include <CLI11/CLI.hpp>
|
|
#include <iostream>
|
|
#include "archive.h"
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
Archive arch;
|
|
|
|
std::string filename;
|
|
std::string directory;
|
|
|
|
CLI::App app("Pack archive files");
|
|
|
|
app.add_option("file", filename, "file name")->required();
|
|
|
|
CLI::App *read = app.add_subcommand("read", "Read files");
|
|
CLI::App *write = app.add_subcommand("write", "Write files");
|
|
app.require_subcommand();
|
|
|
|
//app.add_option("directory", directory, "directory")->required();
|
|
|
|
CLI11_PARSE(app, argc, argv);
|
|
|
|
std::cout << filename << std::endl;
|
|
|
|
if (read->parsed()) {
|
|
|
|
arch.read(filename);
|
|
|
|
for (auto idx : arch.files()) {
|
|
std::string str;
|
|
str.assign(idx.second.begin(), idx.second.end());
|
|
|
|
std::cout << idx.first << ": " << str << std::endl;
|
|
}
|
|
|
|
} else {
|
|
std::string str = "Hello";
|
|
std::vector<uint8_t> data;
|
|
|
|
data.assign(str.begin(), str.end());
|
|
arch.add("some/path", data);
|
|
|
|
std::string str2 = "Hello Again";
|
|
std::vector<uint8_t> data2;
|
|
data2.assign(str2.begin(), str2.end());
|
|
|
|
arch.add("some/other/path", data2);
|
|
|
|
arch.write(filename);
|
|
}
|
|
|
|
return 0;
|
|
} |