mirror of
https://github.com/sametersoylu/argument-parser.git
synced 2026-07-14 01:28:13 +00:00
34 lines
873 B
C++
34 lines
873 B
C++
#ifdef __linux__
|
|
|
|
#include "linux_parser.hpp"
|
|
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
namespace argument_parser {
|
|
linux_parser::linux_parser() {
|
|
std::ifstream command_line_file{"/proc/self/cmdline"};
|
|
std::getline(command_line_file, program_name, '\0');
|
|
for (std::string line; std::getline(command_line_file, line, '\0');) {
|
|
parsed_arguments.emplace_back(line);
|
|
}
|
|
}
|
|
|
|
namespace v2 {
|
|
linux_parser::linux_parser(parser_settings const &settings) {
|
|
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');) {
|
|
ref_parsed_args().emplace_back(line);
|
|
}
|
|
|
|
prepare_help_flag(settings.should_exit_on_help);
|
|
}
|
|
} // namespace v2
|
|
} // namespace argument_parser
|
|
|
|
#endif
|