Skip to content

result_callback is ignored when only one subcommand exists #445

@multimeric

Description

@multimeric

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.

Example Code

import typer

app = typer.Typer(result_callback=lambda x: print(x))

@app.command()
def main() -> str:
    return "foo"

if __name__ == "__main__":
    app()

Description

  • Create a Typed instance
  • Have only a single @app.command()
  • Call the file on the CLI without using the command's name, ie python test.py rather than python test.py main
  • The result_callback is not called. In the example above, that means nothing is printed to stdout.

Operating System

Linux

Operating System Details

Ubuntu 20.10

Typer Version

0.6.1

Python Version

3.9.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion or problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions