A tool for sorting blocks of lines in code files

Sort lists inside '# Keep sorted' blocks. Generic and Bazel files require the comment. Cargo.toml is sorted automatically. .gitignore and CODEOWNERS require --features. Skip sorting with '# keepsorted: ignore file' or '# keepsorted: ignore block'. Comments starting with '#', '//' or '--' are preserved.

Caution: in .gitignore and CODEOWNERS files, pattern order affects semantics — later patterns override earlier ones, and negation patterns must follow what they negate. Use '# keepsorted: ignore block' before any block where order matters.

Return codes:
	0: success, everything went well
	1: syntax errors in input
	2: usage errors: invoked incorrectly
	3: unexpected runtime errors: file I/O problems or internal bugs
	4: check mode failed (reformat is needed)

Usage: keepsorted [OPTIONS] [PATH]

Arguments:
  [PATH]
          File to process (required if '--path' is not used)

Options:
  -p, --path <PATH>
          File to process (conflicts with positional path)

  -r, --recursive
          Process directories recursively

  -f, --features <FEATURE>
          Enable experimental features

          Possible values:
          - gitignore:                Enable sorting for `.gitignore` files. Caution: pattern order affects semantics; use '# keepsorted: ignore block' where order matters
          - codeowners:               Enable sorting for `CODEOWNERS` files. Caution: last matching pattern wins; use '# keepsorted: ignore block' where order matters
          - rust_derive_alphabetical: Alphabetical ordering for `#[derive(...)]` attributes
          - rust_derive_canonical:    Canonical ordering for `#[derive(...)]` attributes

      --check
          alias for '--mode check'

      --diff
          alias for '--mode diff'

      --fix
          alias for '--mode fix'

  -m, --mode <MODE>
          Formatting mode
          
          [default: fix]

          Possible values:
          - check: Verify that the file is already sorted
          - diff:  Print a diff of the required changes
          - fix:   Rewrite the file with sorted content

      --diff-command <COMMAND>
          Custom command for '--mode diff'

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

For more info, visit: https://github.com/maksym-arutyunyan/keepsorted
