mirror of
https://github.com/sametersoylu/argument-parser.git
synced 2026-04-13 03:41:18 +00:00
feat: add help command to linux and macos parsers.
This commit is contained in:
@@ -17,6 +17,7 @@ namespace argument_parser {
|
|||||||
class linux_parser : public v2::base_parser {
|
class linux_parser : public v2::base_parser {
|
||||||
public:
|
public:
|
||||||
linux_parser();
|
linux_parser();
|
||||||
|
using base_parser::display_help;
|
||||||
};
|
};
|
||||||
} // namespace v2
|
} // namespace v2
|
||||||
} // namespace argument_parser
|
} // namespace argument_parser
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace argument_parser {
|
|||||||
class macos_parser : public v2::base_parser {
|
class macos_parser : public v2::base_parser {
|
||||||
public:
|
public:
|
||||||
macos_parser();
|
macos_parser();
|
||||||
|
using base_parser::display_help;
|
||||||
};
|
};
|
||||||
} // namespace v2
|
} // namespace v2
|
||||||
} // namespace argument_parser
|
} // namespace argument_parser
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ namespace argument_parser {
|
|||||||
for (std::string line; std::getline(command_line_file, line, '\0');) {
|
for (std::string line; std::getline(command_line_file, line, '\0');) {
|
||||||
parsed_arguments.emplace_back(line);
|
parsed_arguments.emplace_back(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_argument({{flags::ShortArgument, "h"},
|
||||||
|
{flags::LongArgument, "help"},
|
||||||
|
{flags::Action, helpers::make_non_parametered_action([this]() {
|
||||||
|
this->display_help(this->current_conventions());
|
||||||
|
std::exit(0);
|
||||||
|
})},
|
||||||
|
{flags::HelpText, "Prints this help text."}});
|
||||||
}
|
}
|
||||||
} // namespace v2
|
} // namespace v2
|
||||||
} // namespace argument_parser
|
} // namespace argument_parser
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ namespace argument_parser {
|
|||||||
ref_parsed_args().emplace_back(argv[i]);
|
ref_parsed_args().emplace_back(argv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_argument({{flags::ShortArgument, "h"},
|
||||||
|
{flags::LongArgument, "help"},
|
||||||
|
{flags::Action, helpers::make_non_parametered_action([this]() {
|
||||||
|
this->display_help(this->current_conventions());
|
||||||
|
std::exit(0);
|
||||||
|
})},
|
||||||
|
{flags::HelpText, "Prints this help text."}});
|
||||||
}
|
}
|
||||||
} // namespace v2
|
} // namespace v2
|
||||||
} // namespace argument_parser
|
} // namespace argument_parser
|
||||||
|
|||||||
Reference in New Issue
Block a user