Skip to content

pre-commit-hooks generator duplicates hook args in entry and args (Fourmolu), causing Invalid option '--mode' #116

@perturbing

Description

@perturbing

Hi,

I use this in my nix/shell.nix

      fourmolu = {
        enable = true;
        package = tools.fourmolu;
        args = [ "--mode" "inplace" ];
      };

But this creates the following pre commit yaml file

      "hooks": [
        {
          "always_run": false,
          "args": [
            "--mode",
            "inplace"
          ],
          "entry": "/nix/store/yg4015slpy4dmlmzdvx4fsz3yiy80hfv-fourmolu-exe-fourmolu-0.16.2.0/bin/fourmolu --mode inplace ",
          "exclude": "^$",
          "exclude_types": [],

here you can see that the entry key also includes the arguments --mode inplace! This makes it so that you get the error

Invalid option `--mode'

Usage: fourmolu [-v|--version]
                [--manual-exts]
                [--print-defaults]
                [-i |

                  (-m|--mode MODE)]
                [-q|--quiet]
                [-o|--ghc-opt OPT]
                [-f|--fixity FIXITY]
                [-r|--reexport REEXPORT]
                [-p|--package PACKAGE]
                [-u|--unsafe]
                [-d|--debug]
                [-c|--check-idempotence]
                [--color WHEN]
                [--start-line START]
                [--end-line END]
                [--config CONFIG_FILE]
                [--indentation INT]
                [--column-limit OPTION]
                [--function-arrows OPTION]
                [--comma-style OPTION]
                [--import-export-style OPTION]
                [--indent-wheres BOOL]
                [--record-brace-space BOOL]
                [--newlines-between-decls INT]
                [--haddock-style OPTION]
                [--haddock-style-module OPTION]
                [--let-style OPTION]
                [--in-style OPTION]
                [--single-constraint-parens OPTION]
                [--single-deriving-parens OPTION]
                [--unicode OPTION]
                [--respectful BOOL]
                [--no-cabal]
                [--stdin-input-file ARG]
                [-t|--source-type TYPE]
                [FILE]

when running my pre commit call. For now I just use

args = [ ];

which generates

      "hooks": [
        {
          "always_run": false,
          "args": [],
          "entry": "/nix/store/yg4015slpy4dmlmzdvx4fsz3yiy80hfv-fourmolu-exe-fourmolu-0.16.2.0/bin/fourmolu --mode inplace ",

But I think this unintended behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions