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

Show help items in order of definition, not alphabetically #933

Closed
1 task done
tiangolo opened this issue Aug 17, 2024 · 0 comments · Fixed by #944
Closed
1 task done

Show help items in order of definition, not alphabetically #933

tiangolo opened this issue Aug 17, 2024 · 0 comments · Fixed by #944
Labels
feature New feature, enhancement or request

Comments

@tiangolo
Copy link
Member

Privileged issue

  • I'm @tiangolo or he asked me directly to create an issue here.

Issue Content

Show help items in order of definition, not alphabetically

For example:

import typer

app = typer.Typer()


@app.command()
def first(word: str | None = None):
    """
    First declared command should show up first.
    """
    print(f"first {word}")


@app.command()
def after(word: str | None = None):
    """
    Last declared command should show up last, not alphabetically.
    """
    print(f"after {word}")

This is the current output:

$ typer demo.py run --help
                                                                            
 Usage: typer [PATH_OR_MODULE] run [OPTIONS] COMMAND [ARGS]...              
                                                                            
 Run the provided Typer app.                                                
                                                                            
╭─ Options ────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                              │
╰──────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────╮
│ after   Last declared command should show up last, not alphabetically.   │
│ first   First declared command should show up first.                     │
╰──────────────────────────────────────────────────────────────────────────╯

This is the ideal output:

$ typer demo.py run --help
                                                                            
 Usage: typer [PATH_OR_MODULE] run [OPTIONS] COMMAND [ARGS]...              
                                                                            
 Run the provided Typer app.                                                
                                                                            
╭─ Options ────────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                              │
╰──────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────╮
│ first   First declared command should show up first.                     │
│ after   Last declared command should show up last, not alphabetically.   │
╰──────────────────────────────────────────────────────────────────────────╯
@tiangolo tiangolo added the feature New feature, enhancement or request label Aug 17, 2024
@svlandeg svlandeg removed their assignment Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, enhancement or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants