project-config CLI
Validate the configuration of your project against the configured styles.
project-config [-h] [-v] [-T] [-c CONFIG] [--root ROOTDIR] [-r NAME[:FORMAT];OPTION=VALUE]
[--no-color] [--no-cache]
{check,show,clean}
project-config positional arguments
command
- Command to execute. (default:None
)
project-config optional arguments
-v
,--version
- Show project-config’s version number and exit.-T
,--traceback
- Display the full traceback when a exception is found. Useful for debugging purposes.-c
CONFIG
,--config
CONFIG
- Custom configuration file path. (default:None
)--root
ROOTDIR
,--rootdir
ROOTDIR
- Root directory of the project. Useful if you want to execute project-config for another project rather than the current working directory. (default:None
)-r
NAME[:FORMAT];OPTION=VALUE
,--reporter
NAME[:FORMAT];OPTION=VALUE
- Reporter for generated output when failed. Possible values are'default'
,'json'
,'json:pretty'
,'json:pretty4'
,'toml'
,'yaml'
,'table:fancy_grid'
,'table:fancy_outline'
,'table:github'
,'table:grid'
,'table:html'
,'table:jira'
,'table:latex'
,'table:latex_booktabs'
,'table:latex_longtable'
,'table:latex_raw'
,'table:mediawiki'
,'table:moinmoin'
,'table:orgtbl'
,'table:pipe'
,'table:plain'
,'table:presto'
,'table:pretty'
,'table:psql'
,'table:rst'
,'table:simple'
,'table:textile'
,'table:tsv'
,'table:unsafehtml'
,'table:youtrack'
. Additionally, options can be passed to the reporter appending';'
to the end of the reporter id with the syntax'<OPTION>=<JSON VALUE>'
. Console reporters can take an argument'color'
which accepts a JSON object to customize the colors for parts of the report like files, for example: table:simple;color=``{”file”:”blue”}``. (default:{}
)--no-color
,--nocolor
- Disable colored output. You can also set a value in the environment variable NO_COLOR.--no-cache
,--nocache
- Disable cache for the current execution. You can also set the value'false'
in the environment variable PROJECT_CONFIG_USE_CACHE.
Commands
project-config check
- Check the styles of the current project.project-config show config
- Show the configuration.project-config show style
- Show the collected styles merged into the final one.project-config show plugins
- Show all available plugins with their actions.project-config show cache
- Show cache directory location.project-config clean cache
- Clean the persistent cache of remote collected sources.
Tip
project-config CLI sets the environment variable PROJECT_CONFIG
while
is running.
Reporting
project-config supports multiple formats for reporting. Currently, the following reporters are supported:
default
- The default reporter, based on YAML but simplified.yaml
- YAML reporter with flow style format.json
- JSON reporter.toml
- TOML reporter.table
- Table reporters using tabulate.
When you pass a reporter with the project-config --reporter option, you
can specify the variant of the format with reporter:format
syntax, for
example table:html
will output the errors in an HTML table.
Additional third party reporters can be implemented as plugins, see Writing third party reporters for more information.
The reporter output affects the output of the next commands:
project-config check
project-config show config
project-config show style
project-config show plugins
Note
Keep in mind that errors shown by check
command are redirected to STDERR.
Colorized output can’t be serialized, so if you want to postprocess the report
in the command line use always the project-config --no-color flag or set
the environment variable NO_COLOR
.
Examples of usage
Check the styles of the current project reporting in TOML format without color and making all requests to remote sources:
project-config check -r toml --no-color --no-cache
The installation of project-config from Python sources comes with
the jmespath Python library, which includes the CLI tool jp.py
that can be used to apply JMESPath queries to JSON reports produced by
project-config.
For example, to show the number of incorrect files detected by the
check
command (Unix only):
project-config check -r json --no-color 2>&1 | jp.py 'length(keys(@))'
Show the number of rules defined in your styles after collecting all:
project-config show style -r json --no-color 2>&1 | jp.py 'length(rules)'
Show the number of actions currently available:
project-config show plugins -r json --no-color 2>&1 | jp.py 'length(*[])'
Show your styles after collecting all in YAML format:
project-config show style -r yaml