Skip to content

Commit

Permalink
style: format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
f0e committed Nov 3, 2024
1 parent 861d328 commit 681ed76
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 49 deletions.
48 changes: 24 additions & 24 deletions src/cli/main.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
#include "cli.h"

int main(int argc, char* argv[]) {
CLI::App app{"Add motion blur to videos"};

std::vector<std::string> inputs;
std::vector<std::string> outputs;
std::vector<std::string> configPaths;
bool preview = false;
bool verbose = false;
CLI::App app{ "Add motion blur to videos" };

app.add_option("-i,--input", inputs, "Input file name(s)")
->required();
app.add_option("-o,--output", outputs, "Output file name(s) (optional)");
app.add_option("-c,--config-path", configPaths, "Manual configuration file path(s) (optional)");
app.add_flag("-p,--preview", preview, "Enable preview");
app.add_flag("-v,--verbose", verbose, "Verbose mode");
std::vector<std::string> inputs;
std::vector<std::string> outputs;
std::vector<std::string> configPaths;
bool preview = false;
bool verbose = false;

try {
CLI11_PARSE(app, argc, argv);

cli::run(inputs, outputs, configPaths, preview, verbose);
app.add_option("-i,--input", inputs, "Input file name(s)")
->required();
app.add_option("-o,--output", outputs, "Output file name(s) (optional)");
app.add_option("-c,--config-path", configPaths, "Manual configuration file path(s) (optional)");
app.add_flag("-p,--preview", preview, "Enable preview");
app.add_flag("-v,--verbose", verbose, "Verbose mode");

return 0;
}
catch (const CLI::ParseError &e) {
std::cout << "Failed to parse arguments, use -h or --help for help." << std::endl;
return 1;
}
}
try {
CLI11_PARSE(app, argc, argv);

cli::run(inputs, outputs, configPaths, preview, verbose);

return 0;
}
catch (const CLI::ParseError& e) {
std::cout << "Failed to parse arguments, use -h or --help for help." << std::endl;
return 1;
}
}
3 changes: 1 addition & 2 deletions src/common/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

bool c_blur::initialise(bool _verbose, bool _using_preview) {
path = std::filesystem::path(helpers::get_executable_path()).parent_path(); // folder the exe is in
used_installer = std::filesystem::exists(path / "lib\\vapoursynth\\vspipe.exe")
&& std::filesystem::exists(path / "lib\\ffmpeg\\ffmpeg.exe");
used_installer = std::filesystem::exists(path / "lib\\vapoursynth\\vspipe.exe") && std::filesystem::exists(path / "lib\\ffmpeg\\ffmpeg.exe");

if (!used_installer) {
// didn't use installer, check if dependencies were installed
Expand Down
2 changes: 1 addition & 1 deletion src/common/blur.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class c_blur {
void cleanup();
};

inline c_blur blur;
inline c_blur blur;
6 changes: 3 additions & 3 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void c_config::create(const std::filesystem::path& filepath, s_blur_settings cur
output << "interpolation algorithm: " << current_settings.interpolation_algorithm << "\n";
output << "interpolation block size: " << current_settings.interpolation_blocksize << "\n";
output << "interpolation mask area: " << current_settings.interpolation_mask_area << "\n";

if (current_settings.manual_svp) {
output << "\n";
output << "- manual svp override" << "\n";
Expand Down Expand Up @@ -109,7 +109,7 @@ s_blur_settings c_config::parse(const std::filesystem::path& config_filepath) {

auto config = read_config();

auto config_get = [&]<typename t>(const std::string & var, t & out) {
auto config_get = [&]<typename t>(const std::string& var, t& out) {
if (!config.contains(var)) {
helpers::debug_log(fmt::format("config missing variable '{}'", var));
return;
Expand All @@ -118,7 +118,7 @@ s_blur_settings c_config::parse(const std::filesystem::path& config_filepath) {
try {
std::stringstream ss(config[var]);
ss.exceptions(std::ios::failbit); // enable exceptions
ss >> std::boolalpha >> out; // boolalpha: enable true/false bool parsing
ss >> std::boolalpha >> out; // boolalpha: enable true/false bool parsing
}
catch (const std::exception&) {
helpers::debug_log("failed to parse config variable '{}' (value: {})", var, config[var]);
Expand Down
2 changes: 1 addition & 1 deletion src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ class c_config {
s_blur_settings get_config(const std::filesystem::path& config_filepath, bool use_global);
};

inline c_config config;
inline c_config config;
36 changes: 18 additions & 18 deletions src/common/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ std::vector<std::string> helpers::split_string(std::string str, const std::strin
}

std::wstring helpers::towstring(const std::string& str) {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(str);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(str);
}

std::string helpers::tostring(const std::wstring& wstr) {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.to_bytes(wstr);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.to_bytes(wstr);
}

std::string helpers::to_lower(const std::string& str) {
Expand All @@ -66,22 +66,22 @@ bool helpers::detect_command(const std::string& command) {

std::string helpers::get_executable_path() {
#if defined(_WIN32)
char path[MAX_PATH];
GetModuleFileNameA(NULL, path, MAX_PATH);
return std::string(path);
char path[MAX_PATH];
GetModuleFileNameA(NULL, path, MAX_PATH);
return std::string(path);
#elif defined(__linux__)
char path[PATH_MAX];
ssize_t count = readlink("/proc/self/exe", path, PATH_MAX);
return std::string(path, (count > 0) ? count : 0);
char path[PATH_MAX];
ssize_t count = readlink("/proc/self/exe", path, PATH_MAX);
return std::string(path, (count > 0) ? count : 0);
#elif defined(__APPLE__)
uint32_t size = 0;
_NSGetExecutablePath(nullptr, &size); // Get the required size
std::vector<char> path(size);
if (_NSGetExecutablePath(path.data(), &size) == 0) {
return std::string(path.data());
}
return "";
uint32_t size = 0;
_NSGetExecutablePath(nullptr, &size); // Get the required size
std::vector<char> path(size);
if (_NSGetExecutablePath(path.data(), &size) == 0) {
return std::string(path.data());
}
return "";
#else
#error "Unsupported platform"
# error "Unsupported platform"
#endif
}

0 comments on commit 681ed76

Please sign in to comment.