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

Rich Help Panels are misaligned between each other #441

Closed
7 tasks done
johnthagen opened this issue Aug 8, 2022 · 2 comments
Closed
7 tasks done

Rich Help Panels are misaligned between each other #441

johnthagen opened this issue Aug 8, 2022 · 2 comments
Labels
question Question or problem

Comments

@johnthagen
Copy link

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Typer documentation, with the integrated search.
  • I already searched in Google "How to X in Typer" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to Typer but to Click.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from enum import Enum, unique

from typer import Typer

app = Typer(help="My Typer App.")


@unique
class HelpPanel(str, Enum):
    Installation = "Installation"
    Database = "Database"


@app.command(rich_help_panel=HelpPanel.Installation)
def install() -> None:
    """Install the application"""
    ...


@app.command(rich_help_panel=HelpPanel.Installation)
def uninstall() -> None:
    """Uninstall the application"""
    ...


@app.command(rich_help_panel=HelpPanel.Database)
def backup() -> None:
    """Backup database"""
    ...


@app.command(rich_help_panel=HelpPanel.Database)
def restore() -> None:
    """Restore database"""
    ...


if __name__ == "__main__":
    app()

Description

  • Install Typer with pip install typer[all] or with Poetry to also get rich installed:
[tool.poetry.dependencies]
typer = { version = "*", extras = ["all"] }
  • Create multiple unique rich_help_panels
  • Run with --help and notice that each help panel is indented differently, making it hard for the user to easily read all of the command help text. This problem grows worse as more help panels are added
$ python main.py --help
                                                                                                                                     
 Usage: main.py [OPTIONS] COMMAND [ARGS]...                                                                                          
                                                                                                                                     
 My Typer App.                                                                                                                       
                                                                                                                                     
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --install-completion          Install completion for the current shell.                                                           │
│ --show-completion             Show completion for the current shell, to copy it or customize the installation.                    │
│ --help                        Show this message and exit.                                                                         │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Database ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ backup                                     Backup database                                                                        │
│ restore                                    Restore database                                                                       │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Installation ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ install                              Install the application                                                                      │
│ uninstall                            Uninstall the application                                                                    │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Operating System

macOS

Operating System Details

macOS 11.6.7

Typer Version

0.6.1

Python Version

3.9.13

Additional Context

$ pip list
Package     Version
----------- -------
click       8.1.3
colorama    0.4.5
commonmark  0.9.1
pip         22.2
Pygments    2.12.0
rich        12.5.1
setuptools  62.1.0
shellingham 1.5.0
typer       0.6.1
wheel       0.37.1
@johnthagen johnthagen added the question Question or problem label Aug 8, 2022
@HighnessAtharva
Copy link

Any updates or fixes for this?

@johnthagen
Copy link
Author

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

No branches or pull requests

2 participants