PakhomovAlexander commented on code in PR #1283: URL: https://github.com/apache/ignite-3/pull/1283#discussion_r1018039566
########## modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/connect/ConnectReplCommand.java: ########## @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.cli.commands.connect; + +import static org.apache.ignite.internal.cli.commands.OptionsConstants.CLUSTER_URL_KEY; +import static org.apache.ignite.internal.cli.commands.OptionsConstants.NODE_URL_DESC; + +import jakarta.inject.Inject; +import java.net.URL; +import org.apache.ignite.internal.cli.call.connect.ConnectCall; +import org.apache.ignite.internal.cli.call.connect.ConnectCallInput; +import org.apache.ignite.internal.cli.commands.BaseCommand; +import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline; +import org.apache.ignite.internal.cli.core.converters.UrlConverter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Parameters; + +/** + * Connects to the Ignite 3 node in REPL mode. + */ +@Command(name = "connect", description = "Connects to Ignite 3 node") +public class ConnectReplCommand extends BaseCommand implements Runnable { + /** Node URL option. */ + @Parameters(description = NODE_URL_DESC, descriptionKey = CLUSTER_URL_KEY, converter = UrlConverter.class) + private URL nodeUrl; + + @Inject + private ConnectCall connectCall; + + /** {@inheritDoc} */ + @Override + public void run() { + CallExecutionPipeline.builder(connectCall) Review Comment: If there is the same node that we are connected to now we could display something like "already connected to <nodename>". ########## modules/cli/src/main/java/org/apache/ignite/internal/cli/ReplFactory.java: ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.cli; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import org.apache.ignite.internal.cli.commands.TopLevelCliReplCommand; +import org.apache.ignite.internal.cli.commands.questions.ConnectToClusterQuestion; +import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline; +import org.apache.ignite.internal.cli.core.call.StringCallInput; +import org.apache.ignite.internal.cli.core.exception.handler.DefaultExceptionHandlers; +import org.apache.ignite.internal.cli.core.repl.Repl; +import org.apache.ignite.internal.cli.core.repl.SessionDefaultValueProvider; +import org.apache.ignite.internal.cli.core.repl.executor.ReplExecutorProvider; +import org.apache.ignite.internal.cli.core.repl.prompt.PromptProvider; + +/** + * Class which runs main REPL mode, it's used both when starting directly into the REPL mode and from the `connect` command. + */ +@Singleton +public class ReplFactory { + @Inject + private ReplExecutorProvider replExecutorProvider; + + @Inject + private PromptProvider promptProvider; + + @Inject + private SessionDefaultValueProvider defaultValueProvider; + + @Inject + private ConnectToClusterQuestion question; + + /** + * Enters REPL mode. + */ + public void enterRepl() { + replExecutorProvider.get().execute(Repl.builder() Review Comment: What about entering repl more than once? Would it work? Shall we check if we are already in repl mode? ########## modules/cli/src/main/java/org/apache/ignite/internal/cli/ReplFactory.java: ########## @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.cli; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import org.apache.ignite.internal.cli.commands.TopLevelCliReplCommand; +import org.apache.ignite.internal.cli.commands.questions.ConnectToClusterQuestion; +import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline; +import org.apache.ignite.internal.cli.core.call.StringCallInput; +import org.apache.ignite.internal.cli.core.exception.handler.DefaultExceptionHandlers; +import org.apache.ignite.internal.cli.core.repl.Repl; +import org.apache.ignite.internal.cli.core.repl.SessionDefaultValueProvider; +import org.apache.ignite.internal.cli.core.repl.executor.ReplExecutorProvider; +import org.apache.ignite.internal.cli.core.repl.prompt.PromptProvider; + +/** + * Class which runs main REPL mode, it's used both when starting directly into the REPL mode and from the `connect` command. + */ +@Singleton +public class ReplFactory { Review Comment: `ReplFactory` is a little confusing here because it does not create any instance. It could enter the interactive mode. I think `Repl.startReplMode()` might be better. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
