MonkeyCanCode commented on code in PR #4465:
URL: https://github.com/apache/polaris/pull/4465#discussion_r3285766020


##########
client/python/apache_polaris/cli/constants.py:
##########
@@ -361,3 +362,11 @@ class Hints:
     "~/.polaris"
 )
 CONFIG_FILE = os.path.join(CONFIG_DIR, ".polaris.json")
+REPL_HISTORY_FILE = os.path.join(CONFIG_DIR, ".polaris_repl_history")
+_DEFULT_REPL_HISTORY_LENGTH = 1000
+try:
+    REPL_HISTORY_LENGTH = int(
+        os.environ.get("POLARIS_REPL_HISTORY_LENGTH", 
_DEFULT_REPL_HISTORY_LENGTH)
+    )
+except ValueError:
+    REPL_HISTORY_LENGTH = _DEFULT_REPL_HISTORY_LENGTH

Review Comment:
   Good call. 



##########
client/python/apache_polaris/cli/command/repl.py:
##########
@@ -0,0 +1,146 @@
+#
+# 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.
+#
+
+import os
+import shlex
+import sys
+from dataclasses import dataclass
+from typing import Optional
+from cmd import Cmd
+import readline
+from apache_polaris.cli.command import Command
+from apache_polaris.cli.constants import (
+    Commands,
+    REPL_HISTORY_LENGTH,
+    REPL_HISTORY_FILE,
+)
+from apache_polaris.cli.exceptions import CliError
+from apache_polaris.cli.options.option_tree import OptionTree
+from apache_polaris.cli.options.parser import Parser
+from apache_polaris.sdk.management import PolarisDefaultApi
+from apache_polaris.sdk.management.exceptions import ApiException
+from apache_polaris.cli.command.profiles import ProfilesCommand
+from apache_polaris.cli.polaris_cli import PolarisCli
+from urllib.parse import urlparse
+
+
+@dataclass
+class ReplCommand(Command):
+    """
+    A Command implementation to represent `polaris repl`. This command starts 
an interactive REPL session.
+
+    Example commands:
+        * ./polaris repl
+    """
+
+    profile: Optional[str] = None
+
+    def validate(self) -> None:
+        pass
+
+    def execute(self, api: PolarisDefaultApi) -> None:
+        try:
+            PolarisRepl(api, profile=self.profile).cmdloop()
+        except KeyboardInterrupt:
+            sys.stdout.write("\nExiting REPL session.\n")

Review Comment:
   Fixed.



-- 
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]

Reply via email to