(
port: int | None,
host: str,
proxy: str | None,
headless: bool,
token: bool,
token_password: str | None,
token_password_file: str | None,
base_url: str,
sandbox: bool | None,
skew_protection: bool,
timeout: float | None,
prompt: str | None,
)
| 730 | ) |
| 731 | @click.argument("prompt", required=False) |
| 732 | def new( |
| 733 | port: int | None, |
| 734 | host: str, |
| 735 | proxy: str | None, |
| 736 | headless: bool, |
| 737 | token: bool, |
| 738 | token_password: str | None, |
| 739 | token_password_file: str | None, |
| 740 | base_url: str, |
| 741 | sandbox: bool | None, |
| 742 | skew_protection: bool, |
| 743 | timeout: float | None, |
| 744 | prompt: str | None, |
| 745 | ) -> None: |
| 746 | if sandbox: |
| 747 | from marimo._cli.sandbox import run_in_sandbox |
| 748 | |
| 749 | # TODO: consider adding recommended as well |
| 750 | run_in_sandbox(sys.argv[1:], name=None, additional_features=["lsp"]) |
| 751 | return |
| 752 | |
| 753 | workspace: NotebookWorkspace | None = None |
| 754 | |
| 755 | if prompt is None: |
| 756 | # We support unix-style prompting, cat prompt.txt | marimo new |
| 757 | prompt = _get_stdin_contents() |
| 758 | |
| 759 | if prompt is not None: |
| 760 | import tempfile |
| 761 | |
| 762 | from marimo._ai.text_to_notebook import text_to_notebook |
| 763 | |
| 764 | try: |
| 765 | _maybe_path = Path(prompt) |
| 766 | if _maybe_path.is_file(): |
| 767 | prompt = _maybe_path.read_text(encoding="utf-8") |
| 768 | except OSError: |
| 769 | # is_file() fails when, for example, the "filename" (prompt) is too long |
| 770 | pass |
| 771 | |
| 772 | temp_file = None |
| 773 | try: |
| 774 | notebook_content = text_to_notebook(prompt) |
| 775 | # On Windows, NamedTemporaryFile cannot be reopened unless |
| 776 | # delete=False. |
| 777 | with tempfile.NamedTemporaryFile( |
| 778 | suffix=".py", mode="w", encoding="utf-8", delete=False |
| 779 | ) as temp_file: |
| 780 | temp_file.write(notebook_content) |
| 781 | workspace = infer_workspace(temp_file.name) |
| 782 | |
| 783 | def _cleanup() -> None: |
| 784 | try: |
| 785 | os.unlink(temp_file.name) |
| 786 | except Exception: |
| 787 | pass |
| 788 | |
| 789 | atexit.register(_cleanup) |
nothing calls this directly
no test coverage detected