Move input file / output file out of RenderParams

This commit is contained in:
josh committed 2026-11-01 15:26:46 -05:00
1 parent d71be68fae
commit 88d482dcb3
7 files changed
+12 -9

No files matched your search

+3 -3
View File
@@ -128,12 +128,12 @@ int Cli::run(int argc, char * argv[])
}
else
{
if (this->params.input_file != "")
if (!this->input_file.empty())
{
fprintf(stderr, "Extraneous argument: %s\n", argv[i]);
return 2;
}
this->params.input_file = argv[i];
this->input_file = argv[i];
}
}
return 0;
@@ -190,7 +190,7 @@ int Cli::handle_option(size_t flag_idx, const char * arg_value)
case flag_output:
case flag_output_l:
this->params.output_file = arg_value;
this->output_file = arg_value;
return 0;
case flag_width:
+2
View File
@@ -6,6 +6,8 @@ class Cli
{
public:
RenderParams params;
string_view input_file;
opt<string_view> output_file;
int run(int argc, char * argv[]);
+1 -1
View File
@@ -5,7 +5,7 @@ Engine::Engine(const RenderParams & params)
{
}
int Engine::run()
int Engine::run(string_view input_file, opt<string_view> output_file)
{
return 0;
}
+1 -1
View File
@@ -6,7 +6,7 @@ class Engine
{
public:
Engine(const RenderParams & params);
int run();
int run(string_view input_file, opt<string_view> output_file);
protected:
RenderParams params;
-3
View File
@@ -1,12 +1,9 @@
#pragma once
#include <stddef.h>
#include <string>
struct RenderParams
{
string input_file;
string output_file;
size_t width = 0u;
size_t height = 0u;
};
+4
View File
@@ -1,5 +1,9 @@
#pragma once
#include <optional>
#include <string>
#include <string_view>
using string = std::string;
using string_view = std::string_view;
template <typename T> using opt = std::optional<T>;
+1 -1
View File
@@ -11,5 +11,5 @@ int main(int argc, char * argv[])
return rc - 1;
}
Engine engine(cli.params);
return engine.run();
return engine.run(cli.input_file, cli.output_file);
}