From 6591014c5725c9aa50506993eebaba3b26c57413 Mon Sep 17 00:00:00 2001 From: Antonio Rojas Date: Mon, 7 Apr 2025 23:17:15 +0200 Subject: [PATCH] Add --quiet and --simple-prompt command line arguments These are meant to replace the use of the sage-ipython script in the sage pexpect interface and other third-party UIs --- src/sage/cli/__init__.py | 13 +++++++++++++ src/sage/cli/interactive_shell_cmd.py | 9 ++++++--- src/sage/cli/options.py | 6 ++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/sage/cli/__init__.py b/src/sage/cli/__init__.py index d616b1e1f93..8f0cac437ef 100644 --- a/src/sage/cli/__init__.py +++ b/src/sage/cli/__init__.py @@ -24,6 +24,19 @@ def main() -> int: default=False, help="print additional information", ) + parser.add_argument( + "-q", + "--quiet", + action="store_true", + default=False, + help="do not display the banner", + ) + parser.add_argument( + "--simple-prompt", + action="store_true", + default=False, + help="use simple prompt IPython mode", + ) VersionCmd.extend_parser(parser) JupyterNotebookCmd.extend_parser(parser) diff --git a/src/sage/cli/interactive_shell_cmd.py b/src/sage/cli/interactive_shell_cmd.py index 22f5468374c..8c697f153b0 100644 --- a/src/sage/cli/interactive_shell_cmd.py +++ b/src/sage/cli/interactive_shell_cmd.py @@ -14,12 +14,15 @@ def run(self) -> int: """ # Display startup banner. Do this before anything else to give the user # early feedback that Sage is starting. - from sage.misc.banner import banner - - banner() + if not self.options.quiet: + from sage.misc.banner import banner + banner() from sage.repl.interpreter import SageTerminalApp app = SageTerminalApp.instance() + if self.options.simple_prompt: + app.config['InteractiveShell']['simple_prompt'] = True + app.config['InteractiveShell']['colors'] = 'nocolor' app.initialize([]) return app.start() # type: ignore diff --git a/src/sage/cli/options.py b/src/sage/cli/options.py index 874d21c7ee0..36c210915f2 100644 --- a/src/sage/cli/options.py +++ b/src/sage/cli/options.py @@ -10,6 +10,12 @@ class CliOptions: """Indicates whether verbose output is enabled.""" verbose: bool = False + """Indicates whether the banner should be displayed.""" + quiet: bool = False + + """Indicates whether the IPython simple prompt should be used.""" + simple_prompt: bool = False + """The notebook type to start.""" notebook: str = "jupyter"