mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 13:25:56 +08:00
Improvements to C++ CLI options parsing (support single-letter form)
This commit is contained in:
parent
ea98d97743
commit
52fbe10f3d
@ -5,13 +5,14 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <exception> // std::runtime_error
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/erase.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(setenv) && defined(_putenv_s)
|
||||
@ -500,8 +501,8 @@ DynamicConfig::read_cli(const int argc, const char** argv, t_config_option_keys*
|
||||
if (token == "--") {
|
||||
// stop parsing tokens as options
|
||||
parse_options = false;
|
||||
} else if (parse_options && boost::starts_with(token, "--")) {
|
||||
boost::algorithm::erase_head(token, 2);
|
||||
} else if (parse_options && boost::starts_with(token, "-")) {
|
||||
boost::algorithm::trim_left_if(token, boost::algorithm::is_any_of("-"));
|
||||
// TODO: handle --key=value
|
||||
|
||||
// look for the option def
|
||||
@ -513,7 +514,9 @@ DynamicConfig::read_cli(const int argc, const char** argv, t_config_option_keys*
|
||||
|
||||
if (optdef->cli == token
|
||||
|| optdef->cli == token + '!'
|
||||
|| boost::starts_with(optdef->cli, token + "=")) {
|
||||
|| boost::starts_with(optdef->cli, token + "=")
|
||||
|| boost::starts_with(optdef->cli, token + "|")
|
||||
|| (token.length() == 1 && boost::contains(optdef->cli, "|" + token))) {
|
||||
opt_key = oit->first;
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user