13#include <fmt/compile.h>
14#include <fmt/format.h>
15#include <libassert/assert.hpp>
74 fmt::format_string<std::string> fmt) {
75 if (!std::filesystem::exists(path)) {
76 return (fmt::format(fmt, path.string()) +
" does not exist");
83 fmt::format_string<std::string> fmt) {
86 if (!std::filesystem::is_regular_file(path)) {
87 return (fmt::format(fmt, path.string()) +
" is not a regular file");
94 fmt::format_string<std::string> fmt) {
97 if (!std::filesystem::is_directory(path)) {
98 return (fmt::format(fmt, path.string()) +
" is not a directory");
117 }
catch (std::exception& ex) {
118 return (fmt::format(
"File matcher {:?} is invalid. {}",
file_matcher, ex.what()));
128 if (APP_MODE != AppMode::Professor) {
130 std::string exec_file_name =
file_name.value_or(assignment.get().get_exec_path());
151 auto format(const ::asmgrader::ProgramOptions& from, fmt::format_context& ctx)
const {
155 fmt::format_to(ctx.out(),
"{{verbosity={}, assignment={}, stop_opt={}, color_opt={}, file_name={}",
156 fmt::underlying(from.verbosity), from.assignment_name, fmt::underlying(from.stop_option),
157 fmt::underlying(from.colorize_option), from.file_name));
159 if (asmgrader::APP_MODE == asmgrader::AppMode::Professor) {
160 return fmt::format_to(ctx.out(),
" file_matcher={}, database_path={}, search_path={}", from.file_matcher,
161 from.database_path, from.search_path);
164 return ctx.out() =
'}';
static constexpr auto DEFAULT_REGEX
Definition assignment_file_searcher.hpp:18
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
static GlobalRegistrar & get() noexcept
Safe global singleton pattern (first intro. by Scott Meyers for C++, I think)
Definition global_registrar.cpp:11
static Expected< void, std::string > check_is_elf(const std::filesystem::path &path)
Definition program.cpp:53
#define TRY(val)
If the supplied argument is an error (unexpected) type, then propegate it up the call stack....
Definition error_types.hpp:46
#define TRYE(val, e)
Definition error_types.hpp:42
Definition asm_buffer.hpp:19
Definition program_options.hpp:31
std::filesystem::path database_path
Definition program_options.hpp:63
VerbosityLevel
See Description of Levels for an explaination of each of the levels. Max is just used as a sentinal f...
Definition program_options.hpp:37
@ Summary
Summary (default)
std::string file_matcher
Definition program_options.hpp:62
static Expected< void, std::string > ensure_is_directory(const std::filesystem::path &path, fmt::format_string< std::string > fmt)
Definition program_options.hpp:93
StopOpt
Never = stop only on fatal errors FirstError = stop completely on the first error encountered EachTes...
Definition program_options.hpp:51
static constexpr auto DEFAULT_VERBOSITY_LEVEL
Definition program_options.hpp:71
std::string assignment_name
Definition program_options.hpp:46
enum asmgrader::ProgramOptions::VerbosityLevel verbosity
Expected< void, std::string > validate()
Verify that all fields are valid.
Definition program_options.hpp:105
enum asmgrader::ProgramOptions::ColorizeOpt colorize_option
static Expected< void, std::string > ensure_is_regular_file(const std::filesystem::path &path, fmt::format_string< std::string > fmt)
Definition program_options.hpp:82
std::optional< std::string > file_name
Definition program_options.hpp:59
static Expected< void, std::string > ensure_file_exists(const std::filesystem::path &path, fmt::format_string< std::string > fmt)
Definition program_options.hpp:73
ColorizeOpt
Definition program_options.hpp:53
std::filesystem::path search_path
Definition program_options.hpp:64
static constexpr std::string_view DEFAULT_SEARCH_PATH
Definition program_options.hpp:69
static constexpr std::string_view DEFAULT_FILE_MATCHER
Definition program_options.hpp:70
static constexpr std::string_view DEFAULT_DATABASE_PATH
Definition program_options.hpp:68
enum asmgrader::ProgramOptions::StopOpt stop_option