14#include <fmt/compile.h>
15#include <fmt/format.h>
16#include <libassert/assert.hpp>
65 fmt::format_string<std::string> fmt) {
66 if (!std::filesystem::exists(path)) {
67 return (fmt::format(fmt, path.string()) +
" does not exist");
74 fmt::format_string<std::string> fmt) {
77 if (!std::filesystem::is_regular_file(path)) {
78 return (fmt::format(fmt, path.string()) +
" is not a regular file");
85 fmt::format_string<std::string> fmt) {
88 if (!std::filesystem::is_directory(path)) {
89 return (fmt::format(fmt, path.string()) +
" is not a directory");
108 }
catch (std::exception& ex) {
109 return (fmt::format(
"File matcher {:?} is invalid. {}",
file_matcher, ex.what()));
121 std::string exec_file_name =
file_name.value_or(assignment.get().get_exec_path());
142 auto format(const ::asmgrader::ProgramOptions& from, fmt::format_context& ctx)
const {
146 fmt::format_to(ctx.out(),
"{{verbosity={}, assignment={}, stop_opt={}, color_opt={}, file_name={}",
147 fmt::underlying(from.verbosity), from.assignment_name, fmt::underlying(from.stop_option),
148 fmt::underlying(from.colorize_option), from.file_name));
151 return fmt::format_to(ctx.out(),
" file_matcher={}, database_path={}, search_path={}", from.file_matcher,
152 from.database_path, from.search_path);
155 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_compat_elf(const std::filesystem::path &path)
Definition program.cpp:58
#define TRY(val)
If the supplied argument is an error (unexpected) type, then propegate it up the call stack....
Definition error_types.hpp:52
#define TRYE(val, e)
Definition error_types.hpp:48
Definition asm_buffer.hpp:20
constexpr auto APP_MODE
Definition version.hpp:46
VerbosityLevel
See Description of Levels for an explaination of each of the levels. Max is just used as a sentinal f...
Definition verbosity.hpp:9
@ Summary
Summary (default)
Definition program_options.hpp:30
std::filesystem::path database_path
Definition program_options.hpp:54
std::string file_matcher
Definition program_options.hpp:53
static Expected< void, std::string > ensure_is_directory(const std::filesystem::path &path, fmt::format_string< std::string > fmt)
Definition program_options.hpp:84
StopOpt
Never = stop only on fatal errors FirstError = stop completely on the first error encountered EachTes...
Definition program_options.hpp:42
static constexpr auto DEFAULT_VERBOSITY_LEVEL
Definition program_options.hpp:62
std::string assignment_name
Definition program_options.hpp:37
Expected< void, std::string > validate()
Verify that all fields are valid.
Definition program_options.hpp:96
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:73
std::optional< std::string > file_name
Definition program_options.hpp:50
static Expected< void, std::string > ensure_file_exists(const std::filesystem::path &path, fmt::format_string< std::string > fmt)
Definition program_options.hpp:64
ColorizeOpt
Definition program_options.hpp:44
VerbosityLevel verbosity
Level of verbosity for cli output. See Description of Levels for an explaination of each of the level...
Definition program_options.hpp:36
std::filesystem::path search_path
Definition program_options.hpp:55
static constexpr std::string_view DEFAULT_SEARCH_PATH
Definition program_options.hpp:60
static constexpr std::string_view DEFAULT_FILE_MATCHER
Definition program_options.hpp:61
static constexpr std::string_view DEFAULT_DATABASE_PATH
Definition program_options.hpp:59
enum asmgrader::ProgramOptions::StopOpt stop_option