Skip to content

Commit

Permalink
docs: fix generating --help-all output in CLI reference
Browse files Browse the repository at this point in the history
  • Loading branch information
sisp committed Oct 2, 2023
1 parent e97d673 commit 092b304
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions copier/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@
```
Below are the docs of each one of those.
CLI help generated from `copier --help-all`:
```sh exec="on" result="text"
copier --help-all
```
"""

import sys
from io import StringIO
from pathlib import Path
from textwrap import dedent
from unittest.mock import patch

import yaml
from decorator import decorator
Expand Down Expand Up @@ -406,12 +410,3 @@ def main(self, destination_path: cli.ExistingDirectory = ".") -> int:
) as worker:
worker.run_update()
return 0


# Add --help-all results to docs
if __doc__:
help_io = StringIO()
with patch("sys.stdout", help_io):
CopierApp.run(["copier", "--help-all"], exit=False)
help_io.seek(0)
__doc__ += f"\n\nCLI help generated from `copier --help-all`:\n\n```\n{help_io.read()}\n```"

0 comments on commit 092b304

Please sign in to comment.