diff --git a/src/commands.cc b/src/commands.cc index 693706e8..3b19e5f7 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -597,7 +597,7 @@ void define_command(const ParametersParser& parser, Context& context) ParameterDesc desc; if (parser.has_option("env-params")) { - desc = ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::None }; + desc = ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::SwitchesAsPositional }; cmd = [=](const ParametersParser& parser, Context& context) { CommandManager::instance().execute(commands, context, {}, params_to_env_var_map(parser)); @@ -605,14 +605,14 @@ void define_command(const ParametersParser& parser, Context& context) } if (parser.has_option("shell-params")) { - desc = ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::None }; + desc = ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::SwitchesAsPositional }; cmd = [=](const ParametersParser& parser, Context& context) { CommandManager::instance().execute(commands, context, params_to_shell(parser)); }; } else { - desc = ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::None, 0, 0 }; + desc = ParameterDesc{ SwitchMap{}, ParameterDesc::Flags::SwitchesAsPositional, 0, 0 }; cmd = [=](const ParametersParser& parser, Context& context) { CommandManager::instance().execute(commands, context); }; diff --git a/src/parameters_parser.cc b/src/parameters_parser.cc index 76f92d72..68e15791 100644 --- a/src/parameters_parser.cc +++ b/src/parameters_parser.cc @@ -16,7 +16,7 @@ ParametersParser::ParametersParser(ParameterList params, : m_params(params), m_desc(desc) { - bool only_pos = false; + bool only_pos = desc.flags & ParameterDesc::Flags::SwitchesAsPositional; for (size_t i = 0; i < params.size(); ++i) { if (params[i] == "--") diff --git a/src/parameters_parser.hh b/src/parameters_parser.hh index a7773476..b41dc9a0 100644 --- a/src/parameters_parser.hh +++ b/src/parameters_parser.hh @@ -50,6 +50,7 @@ struct ParameterDesc { None = 0, SwitchesOnlyAtStart = 1, + SwitchesAsPositional = 2, }; friend constexpr Flags operator|(Flags lhs, Flags rhs) {