Skip to content

Commit 2fba17b

Browse files
committed
Simplify the launcher
Having `if __name__ == "__main__"` in `__main__.py` is redundant, because the `greetings` module itself is runnable due to the mere existence of the `__main__.py` file. Importing just the `main()` function is likely more common and concise than relying on the heavy-weight `app` object to be callable.
1 parent 01a7007 commit 2fba17b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

source/guides/creating-command-line-tools.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,11 @@ so initialize the command-line interface here:
9090

9191
.. code-block:: python
9292
93-
if __name__ == "__main__":
94-
from greetings.cli import app
95-
app()
93+
import sys
94+
95+
from greetings.cli import main
96+
97+
sys.exit(main())
9698
9799
.. note::
98100

0 commit comments

Comments
 (0)