diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-11-12 19:38:19 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-11-12 19:38:19 +0000 |
| commit | 0244112af42f5a4e027705dd68b662fb2c795cce (patch) | |
| tree | 0eeacacc746bd8557c9b1d8644dff0a66670bb25 /src/command_manager.cc | |
| parent | 5a4650aecc20d6f13abe0193d0d5886a51a43af4 (diff) | |
Add support for hidden commands, that will not show on completion
Diffstat (limited to 'src/command_manager.cc')
| -rw-r--r-- | src/command_manager.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/command_manager.cc b/src/command_manager.cc index 165a58f3..74468c06 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -18,17 +18,19 @@ bool CommandManager::command_defined(const String& command_name) const void CommandManager::register_command(String command_name, Command command, + CommandFlags flags, CommandCompleter completer) { - m_commands[command_name] = { std::move(command), std::move(completer) }; + m_commands[command_name] = { std::move(command), flags, std::move(completer) }; } void CommandManager::register_commands(memoryview<String> command_names, Command command, + CommandFlags flags, CommandCompleter completer) { for (auto command_name : command_names) - m_commands[command_name] = { command, completer }; + m_commands[command_name] = { command, flags, completer }; } struct parse_error : runtime_error @@ -337,7 +339,9 @@ Completions CommandManager::complete(const Context& context, CompletionFlags fla for (auto& command : m_commands) { - if (prefix_match(command.first, prefix)) + if (command.second.flags & CommandFlags::Hidden) + continue; + if ( prefix_match(command.first, prefix)) result.candidates.push_back(command.first); } std::sort(result.candidates.begin(), result.candidates.end()); |
