mirror of
https://github.com/sametersoylu/argument-parser.git
synced 2026-04-12 19:31:18 +00:00
chore: add v2 version of the linux parser
This commit is contained in:
@@ -5,12 +5,20 @@
|
||||
#define LINUX_PARSER_HPP
|
||||
|
||||
#include <argument_parser.hpp>
|
||||
#include <parser_v2.hpp>
|
||||
|
||||
namespace argument_parser {
|
||||
class linux_parser : public base_parser {
|
||||
public:
|
||||
linux_parser();
|
||||
};
|
||||
|
||||
namespace v2 {
|
||||
class linux_parser : public v2::base_parser {
|
||||
public:
|
||||
linux_parser();
|
||||
};
|
||||
} // namespace v2
|
||||
} // namespace argument_parser
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,6 +13,19 @@ namespace argument_parser {
|
||||
parsed_arguments.emplace_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
namespace v2 {
|
||||
linux_parser::linux_parser() {
|
||||
std::ifstream command_line_file{"/proc/self/cmdline"};
|
||||
std::string program_name;
|
||||
std::getline(command_line_file, program_name, '\0');
|
||||
set_program_name(program_name);
|
||||
|
||||
for (std::string line; std::getline(command_line_file, line, '\0');) {
|
||||
parsed_arguments.emplace_back(line);
|
||||
}
|
||||
}
|
||||
} // namespace v2
|
||||
} // namespace argument_parser
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user