nginxinc / crossplane

Quick and reliable way to convert NGINX configurations into JSON and back.
Apache License 2.0
717 stars 86 forks source link

feat: support formatting multiple files at once #62

Closed josegonzalez closed 5 years ago

josegonzalez commented 5 years ago

Formatting currently bails when being given a directory:

Traceback (most recent call last):
  File "/usr/local/bin/crossplane", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/crossplane/__main__.py", line 222, in main
    func(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/crossplane/__main__.py", line 127, in format
    output = format_file(filename, indent=indent, tabs=tabs)
  File "/usr/local/lib/python3.6/site-packages/crossplane/formatter.py", line 12, in format
    raise NgxParserBaseException(e['error'], e['file'], e['line'])
crossplane.errors.NgxParserBaseException: <exception str() failed>

Seems adding support for a directory could be useful for allowing this to be used in CI for enforcing lint rules.

The codebase should also have the option to list files whose formatting differs from crossplane's.

aluttik commented 5 years ago

We are not building crossplane with CI in mind. If you would like to use crossplane for CI linting, then it would be pretty simple to write a script using the crossplane Python API. Thanks for the request, but I'm going to close this.