Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include port in console run hint #9

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rafraser
Copy link

This PR adds the --port argument to the run hint provided by the Textual dev console.

image

Unfortunately, something I'm working on also uses port 8081, so whenever I'm using the Textual console I'm always using a different port. This is a pretty minor addition but it'd make things ever-so-slightly easier for me!

Copy link
Contributor

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Just a request for a docstring. We like everything to have docstrings, even if it occasionally seems redundant...

@@ -45,6 +46,12 @@ def __rich_console__(
yield from line
yield new_line

def _run_command(self) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring please!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I also added a docstring to the DevConsoleHeader class to match the other renderables in the file

@steven-r
Copy link

I've stumbled over the same problem. Currently I'm using the pull request sources to use the --dev mode but would like to switch back to the regular version as I face problems with 'textual keys'.

@willmcgugan
Copy link
Contributor

I've stumbled over the same problem. Currently I'm using the pull request sources to use the --dev mode but would like to switch back to the regular version as I face problems with 'textual keys'.

This PR displays the port, but it doesn't implement the --dev switch which has existed for months. What problem are you having with textual keys?

@steven-r
Copy link

This PR displays the port, but it doesn't implement the --dev switch which has existed for months. What problem are you having with textual keys?

This was misleading... I wanted to refer to the --port-option. When using the this branch and starttextual keys, I get the following stacktrace:

  File "/Users/.../Documents/GitHub/mybook/venv/bin/textual", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/textual_dev/cli.py", line 225, in keys
    from textual_dev.previews import KeysApp
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/textual_dev/previews/__init__.py", line 6, in <module>
    from .keys import KeysApp
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/textual_dev/previews/keys.py", line 11, in <module>
    from textual.widgets import Button, Header, TextLog
  File "/Users/.../Documents/GitHub/mybook/venv/lib/python3.11/site-packages/textual/widgets/__init__.py", line 96, in __getattr__
    raise ImportError(f"Package 'textual.widgets' has no class '{widget_class}'")
ImportError: Package 'textual.widgets' has no class 'TextLog'

@willmcgugan
Copy link
Contributor

You have old code. Please update Textual abs textual-dev

@steven-r
Copy link

steven-r commented Sep 1, 2023

You have old code. Please update Textual abs textual-dev

Well, sorry, my fault.

@willmcgugan
Copy link
Contributor

No worries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants