mirror of
https://github.com/sametersoylu/argument-parser.git
synced 2026-04-13 03:41:18 +00:00
chore: add v2 version of the linux parser
This commit is contained in:
@@ -5,12 +5,20 @@
|
|||||||
#define LINUX_PARSER_HPP
|
#define LINUX_PARSER_HPP
|
||||||
|
|
||||||
#include <argument_parser.hpp>
|
#include <argument_parser.hpp>
|
||||||
|
#include <parser_v2.hpp>
|
||||||
|
|
||||||
namespace argument_parser {
|
namespace argument_parser {
|
||||||
class linux_parser : public base_parser {
|
class linux_parser : public base_parser {
|
||||||
public:
|
public:
|
||||||
linux_parser();
|
linux_parser();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace v2 {
|
||||||
|
class linux_parser : public v2::base_parser {
|
||||||
|
public:
|
||||||
|
linux_parser();
|
||||||
|
};
|
||||||
|
} // namespace v2
|
||||||
} // namespace argument_parser
|
} // namespace argument_parser
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,6 +13,19 @@ namespace argument_parser {
|
|||||||
parsed_arguments.emplace_back(line);
|
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
|
} // namespace argument_parser
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user