Newer
Older
#include "file_system.h"
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
args::ArgumentParser argParser("CZI file tools", "Optional arguments are in [ ] necessary in < >.");
args::Group cziFileGroup(argParser, "CZI file input - necessary.", args::Group::Validators::All);
args::Group mainMethodGroup(argParser, "Main method - what to do with parsed file", args::Group::Validators::AtMostOne);
args::Group parserOptionsGroup(argParser, "CZI parser options", args::Group::Validators::DontCare);
args::Group optionsGroup(argParser, "Program options", args::Group::Validators::DontCare);
args::ValueFlag<std::string> cziFile(cziFileGroup, "czi file", "CZI file to load.", {'i', "input"});
args::HelpFlag helpMethod(mainMethodGroup, "help", "Print help", {'h', "help"});
args::Flag reportMethod(mainMethodGroup, "report", "Basic information about CZI file. [verbose]", {"report"});
args::Flag dontParseMetadataOption(parserOptionsGroup, "no metadata", "Dont read metadata byte", {"no-metadata"});
args::Flag verboseOption(optionsGroup, "verbose", "Extend output of method", {'v', "verbose"});
try
{
argParser.ParseCLI(argc, argv);
}
catch (args::Help)
{
std::cout << argParser;
return 0;
}
catch (args::ValidationError e)
{
std::cout << e.what() << std::endl;
std::cout << argParser;
return 1;
}
catch (args::ParseError pe)
{
std::cout << pe.what() << std::endl;
std::cout << argParser;
return 1;
}
/*
std::string cziFile = (argc > 1) ? argv[1] : "/home/mor0146/gitlab/data_project/czi-format/data/CZT-Stack-Anno.czi"; //"/home/mor0146/gitlab/data_project/czi-format/data/m2/exampleSingleChannel.czi";
if (cziFile == "-v" || cziFile == "--version")
{
#if DEBUG
printf("Running `Debug` version\n.");
#else
printf("Running `Release` version\n.");
#endif
return 0;
}
always_assert(is_file(cziFile));
std::string method = argc > 2 ? argv[2] : "";
std::string dumpName = argc > 3 ? argv[3] : "";
bool report = method == "--report";
bool reportAll = method == "--report-verbose";
bool dumpImageData = method == "--dump-images";
bool nextImageDiff = method == "--diff-next";
auto name = get_filename_without_extension(cziFile);
auto x = get_files_in_parent_directory(cziFile, true);
auto y = get_files_with_same_prefix(x, name);
CziParser parser;
auto parseResult = parser.parse_czi_file(cziFile);
if (reportAll)
parseResult.report_verbose();
else if (report)
parseResult.report();
parseResult.extract_images(dumpName);
else if (nextImageDiff)
{
always_assert(dumpName != "");
parseResult.differences_between_next(dumpName);
}
else if (testRle)
{
parseResult.test_rle_encode();
}
printf("Finished.\n");