Skip to content

Commit

Permalink
Add --print-config CLI flag to print the configuration for the give…
Browse files Browse the repository at this point in the history
…n file
  • Loading branch information
thibaudcolas committed May 14, 2020
1 parent 996b0a2 commit be1bbc3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
## Unreleased

### Added

- Add `--print-config` CLI flag to print the configuration for the given file.

## [v0.9.0](https://github.com/thibaudcolas/curlylint/releases/tag/v0.9.0) 2020-05-14

### Added
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ Don’t lint, check for syntax errors and exit.
curlylint --parse-only template-directory/
```

#### `--print-config`

Print the configuration for the given file, and exit.

```sh
curlylint --print-config some-file.html
```

#### `--rule`

Specify rules, with the syntax `--rule 'code: {"json": "value"}'`. Can be provided multiple times to configure multiple rules.
Expand Down
7 changes: 7 additions & 0 deletions curlylint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def path_empty(
is_flag=True,
help="Don’t lint, check for syntax errors and exit.",
)
@click.option(
"--print-config",
is_flag=True,
help="Print the configuration for the given file.",
is_eager=True,
)
@click.option(
"-f",
"--format",
Expand Down Expand Up @@ -148,6 +154,7 @@ def main(
verbose: bool,
quiet: bool,
parse_only: bool,
print_config: bool,
config: Optional[str],
format: str,
stdin_filepath: str,
Expand Down
4 changes: 4 additions & 0 deletions curlylint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def read_pyproject_toml(
if not config:
return None

if ctx.params.get("print_config", False):
print(toml.dumps({"tool": {"curlylint": config}}))
ctx.exit(0)

if ctx.default_map is None:
ctx.default_map = {}
ctx.default_map.update(config) # type: ignore # bad types in .pyi
Expand Down
1 change: 0 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Most of curlylint’s CLI is already based on that of black: include/excludes, c
- Support using a file with ignore paths.
- Disable colored output.
- Cache results / only check changed files.
- Print config for the given file.

## Linting ideas

Expand Down

0 comments on commit be1bbc3

Please sign in to comment.