Skip to content

Commit

Permalink
blackd: show default values for options (#3712)
Browse files Browse the repository at this point in the history
* blackd: show default values for options

Reference: https://click.palletsprojects.com/en/8.1.x/api/#click.Option

* Fix spacing in CHANGES.md
  • Loading branch information
joelsgp committed May 31, 2023
1 parent a4032dc commit a538ab7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Expand Up @@ -44,6 +44,9 @@

<!-- Changes to blackd -->

- The `blackd` argument parser now shows the default values for options in their help
text (#3712)

### Integrations

<!-- For example, Docker, GitHub Actions, pre-commit, editors -->
Expand Down
10 changes: 8 additions & 2 deletions src/blackd/__init__.py
Expand Up @@ -59,9 +59,15 @@ class InvalidVariantHeader(Exception):

@click.command(context_settings={"help_option_names": ["-h", "--help"]})
@click.option(
"--bind-host", type=str, help="Address to bind the server to.", default="localhost"
"--bind-host",
type=str,
help="Address to bind the server to.",
default="localhost",
show_default=True,
)
@click.option(
"--bind-port", type=int, help="Port to listen on", default=45484, show_default=True
)
@click.option("--bind-port", type=int, help="Port to listen on", default=45484)
@click.version_option(version=black.__version__)
def main(bind_host: str, bind_port: int) -> None:
logging.basicConfig(level=logging.INFO)
Expand Down

0 comments on commit a538ab7

Please sign in to comment.