Complete option values with the current value of the option

Fixes #32
This commit is contained in:
Maxime Coste 2014-05-05 12:55:04 +01:00
parent 36620f8cc8
commit dfb1246697
2 changed files with 13 additions and 0 deletions

View File

@ -786,6 +786,14 @@ const CommandDesc set_option_cmd = {
return { 0_byte, params[1].length(),
options.complete_option_name(params[1], pos_in_token) };
}
else if (token_to_complete == 2 and
GlobalOptions::instance().option_exists(params[1]))
{
OptionManager& options = get_options(params[0], context);
String val = options[params[1]].get_as_string();
if (prefix_match(val, params[2]))
return { 0_byte, params[2].length(), { std::move(val) } };
}
return Completions{};
},
[](const ParametersParser& parser, Context& context)

View File

@ -220,6 +220,11 @@ public:
value, std::move(checker)});
return *m_options.back();
}
bool option_exists(const String& name) const
{
return find_option(m_options, name) != m_options.end();
}
private:
std::vector<std::unique_ptr<OptionDesc>> m_descs;
};