@@ -2038,7 +2038,7 @@ template<size_t... P>
20382038ParameterDesc make_context_wrap_params_impl (Array<HashItem<String, SwitchDesc>, sizeof ...(P)>&& additional_params,
20392039 std::index_sequence<P...>)
20402040{
2041- return { { { " client" , { {client_arg_completer}, " run in given client context" } },
2041+ return { { { " client" , { {client_arg_completer}, " run in the client context for each client in the given comma separatd list " } },
20422042 { " try-client" , { {client_arg_completer}, " run in given client context if it exists, or else in the current one" } },
20432043 { " buffer" , { {complete_buffer_name<false >}, " run in a disposable context for each given buffer in the comma separated list argument" } },
20442044 { " draft" , { {}, " run in a disposable context" } },
@@ -2188,14 +2188,25 @@ void context_wrap(const ParametersParser& parser, Context& context, StringView d
21882188 };
21892189
21902190 ClientManager& cm = ClientManager::instance ();
2191- if (auto client_name = parser.get_switch (" client" ))
2192- context_wrap_for_context (cm.get_client (*client_name).context ());
2193- else if (auto client_name = parser.get_switch (" try-client" ))
2191+ if (auto client_names = parser.get_switch (" client" ))
21942192 {
2195- if (Client* client = cm.get_client_ifp (*client_name))
2196- context_wrap_for_context (client->context ());
2193+ if (*client_names == " *" )
2194+ {
2195+ for (auto && client : ClientManager::instance ()
2196+ | transform (&std::unique_ptr<Client>::get)
2197+ | gather<Vector<SafePtr<Client>>>()) // gather as we might be mutating the client list in the loop.
2198+ context_wrap_for_context (client->context ());
2199+ }
21972200 else
2198- context_wrap_for_context (context);
2201+ for (auto && name : *client_names
2202+ | split<StringView>(' ,' , ' \\ ' )
2203+ | transform (unescape<' ,' , ' \\ ' >))
2204+ context_wrap_for_context (ClientManager::instance ().get_client (name).context ());
2205+ }
2206+ else if (auto client_name = parser.get_switch (" try-client" ))
2207+ {
2208+ Client* client = cm.get_client_ifp (*client_name);
2209+ context_wrap_for_context (client ? client->context () : context);
21992210 }
22002211 else
22012212 context_wrap_for_context (context);
0 commit comments