mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
This is a follow up to the repository based coursier integration. The
standard coursier integration is to this integration what the docker
integration is to the docker_image integration.
This is meant to target either maven coordinates or coursier apps
directly without depending on a hook repository containing app
descriptors and hook configs making this integration highly suitable
for local hooks.
An example of hook local targets are bellow
```yaml
- repo: local
hooks:
- id: scalafmt
name: scalafmt
entry: scalafmt # coursier app target
language: coursier_launch
files: (\.scala|\.sbt|\.sc)$
- id: scalafix
name: scalafix
entry: ch.epfl.scala:::scalafix-cli:latest.release # maven coordinates target
language: coursier_launch
files: (\.scala|\.sbt|\.sc)$
- id: echo-java
name: echo-java
entry: echo-java
language: coursier_launch
args: ["--", "hello from java"] # forward arguments to the app
```
28 lines
739 B
Python
Executable file
28 lines
739 B
Python
Executable file
#!/usr/bin/env python3
|
|
import sys
|
|
|
|
LANGUAGES = [
|
|
'conda', 'coursier', 'coursier_launch', 'docker', 'dotnet', 'docker_image',
|
|
'fail', 'golang', 'node', 'perl', 'pygrep', 'python', 'ruby', 'rust',
|
|
'script', 'swift', 'system',
|
|
]
|
|
FIELDS = [
|
|
'ENVIRONMENT_DIR', 'get_default_version', 'healthy', 'install_environment',
|
|
'run_hook',
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
print(f' # BEGIN GENERATED ({sys.argv[0]})')
|
|
for lang in LANGUAGES:
|
|
parts = [f' {lang!r}: Language(name={lang!r}']
|
|
for k in FIELDS:
|
|
parts.append(f', {k}={lang}.{k}')
|
|
parts.append('), # noqa: E501')
|
|
print(''.join(parts))
|
|
print(' # END GENERATED')
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
exit(main())
|