AsmGrader 0.0.0
Loading...
Searching...
No Matches
cl_args.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "common/expected.hpp"
5
6#include <argparse/argparse.hpp>
7
8#include <optional>
9#include <span>
10#include <string>
11#include <string_view>
12#include <vector>
13
14namespace asmgrader {
15
18{
19public:
20 explicit CommandLineArgs(std::span<const char*> args);
21
26
27 std::string usage_message() const;
28 std::string help_message() const;
29
30 std::optional<ProgramOptions> get_options() const;
31
32private:
34 void setup_parser();
35
38 static std::string get_basename(std::string_view full_name);
39
40 argparse::ArgumentParser arg_parser_;
41 std::vector<std::string> args_;
42
43 ProgramOptions opts_buffer_ = {};
44
45 bool parse_successful_ = false;
46};
47
48ProgramOptions parse_args_or_exit(std::span<const char*> args, int exit_code = 1) noexcept;
49
50} // namespace asmgrader
Just a wrapper around argparse for now.
Definition cl_args.hpp:18
CommandLineArgs(std::span< const char * > args)
Definition cl_args.cpp:31
std::optional< ProgramOptions > get_options() const
Expected< ProgramOptions, std::string > parse()
Returns: Success - Expected<ProgramOptions> with parsed program options structure Failure - Expected<...
Definition cl_args.cpp:207
std::string help_message() const
Definition cl_args.cpp:227
std::string usage_message() const
Definition cl_args.cpp:231
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
Definition asm_buffer.hpp:19
ProgramOptions parse_args_or_exit(std::span< const char * > args, int exit_code) noexcept
Definition cl_args.cpp:239
Definition program_options.hpp:31