Commit Graph

17 Commits (2d931b5a817337fa88aef4325bf613e794e14d52)

Author SHA1 Message Date
Adrien Vergé 5060917e40 style(cli): Space import sections 9 years ago
Adrien Vergé df26cc0438 feat(config): Add support to ignore paths on per-rule basis
Example of configuration to use this feature:

    # For all rules
    ignore: |
      *.dont-lint-me.yaml
      /bin/
      !/bin/*.lint-me-anyway.yaml

    rules:
      key-duplicates:
        ignore: |
          generated
          *.template.yaml
      trailing-spaces:
        ignore: |
          *.ignore-trailing-spaces.yaml
          /ascii-art/*

Closes #43.
9 years ago
sedrubal 30dfa78923
Use argparse mutually_exclusive_group for --config-file and --config-data
This does the same as your solution 😉
9 years ago
Jonathan Sokolowski 03e0f5aa6b Add strict mode argument to CLI 9 years ago
Adrien Vergé a2c68fdf9b feat(cli): Colour output only on TTY
When piping yamllint output to a file, "coloured" characters aren't
interpreted and pollute text formatting with glyphs like:

  �[4m./global.yaml�[0m
    �[2m1439:52�[0m   �[31merror�[0m    no new line character...

With this commit, stdout is checked: if it's a TTY then output is
coloured, otherwise output is simple text.

Closes: #14
9 years ago
Adrien Vergé 8c839a20c2 Config: Detect user config using `os.path.expanduser()`
Instead of `$HOME`, since the former works when `$HOME` is not set.

[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=828033#10
10 years ago
Adrien Vergé eabd349902 Config: Allow a user-global configuration file
Instead of just looking for `.yamllint` in the current working
directory, also look for `~/.config/yamllint/config` (using
`$XDG_CONFIG_HOME` or `$HOME`, see [1] and [2] for information).

[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html
[2]: https://wiki.archlinux.org/index.php/XDG_Base_Directory_support

Closes: #6
10 years ago
Adrien Vergé 59d5bffbec Tests: cli: Detect and handle the `-d ''` case 10 years ago
Adrien Vergé 0c36d0175c cli: Print EnvironmentErrors on stderr
Errors such as "no such file or directory" should not be printed on
standard output.
10 years ago
Adrien Vergé 7688567faa cli: Add the `-d` option to provide inline conf 10 years ago
Adrien Vergé 3ab3784a75 cli: Remove shebang
A shebang is present at the beginning of file, it dates from the time
when `yamllint/cli.py` was `bin/yamllint`, i.e. an executable launcher.
Since this is not the case anymore (see `entry_points` section in
`setup.py`), let's remove it.
10 years ago
Adrien Vergé be998593dd Distribution: Create script with `setup.py` 10 years ago
Adrien Vergé dbbecb5875 Refactor project layout to import yamllint alone
Currently importing yamllint recursively imports its submodules, which
finally requires having pyyaml installed. This is a problem when you
just want to import APP_VERSION from yamllint. For instance, setup.py
imports yamllint to know the version, but doesn't know yet that pyyaml
is to be installed, because it is stated in setup.py itself.

To solve this, yamllint/__init__.py will only contain constants. The
linting functions will be in yamllint/linter.py.
10 years ago
Adrien Vergé fc108e7cee Config: Refactor to use YamlLintConfig objects 10 years ago
Adrien Vergé 75b4758c95 cli: 'standard' format: Print filename only when error 10 years ago
Adrien Vergé 0e98df2643 cli: Allow passing directories as arguments
For instance:

    yamllint .
    yamllint file.yml ../my-other-dir
10 years ago
Adrien Vergé d4189083d0 Introduce the 'cli' module and call it from the script 10 years ago