Porytiles
Loading...
Searching...
No Matches
validators.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <expected>
4#include <filesystem>
5#include <format>
6#include <unordered_set>
7
8#include "CLI/CLI.hpp"
9
13
14class NotAlreadyAFileValidator final : public CLI::Validator {
15 static constexpr auto kHint = "PATH";
16
17 public:
18 explicit NotAlreadyAFileValidator() : Validator{kHint}
19 {
20 name_ = "NOT_ALREADY_A_FILE";
21 func_ = [](const std::string &str) {
22 if (std::filesystem::exists(str) && std::filesystem::is_regular_file(str)) {
23 return std::string{"file already exists: " + str};
24 }
25 return std::string{};
26 };
27 }
28};
Utility functions for string manipulation and formatting.