Skip to content

--dir flag not recognized in v3 despite documentation #1129

@niklod

Description

@niklod

Description

Problem

I'm attempting to migrate from mockery v2 to v3. In v2, I successfully used the --dir flag to generate mocks for specific directories:

mockery --dir internal/path/ \
  --inpackage \
  --all

After upgrading to v3, this command now fails with:

Error: unknown flag: --dir

Expected Behavior

According to the v3 configuration documentation, the parameter table lists dir as a configuration option with a default value of "{{.InterfaceDir}}". The documentation states:

"Config can not only be specified from the .yml file, but also from CLI parameters (where available) and environment variables."

This suggests that dir should be available as a CLI flag, similar to how other parameters like --all, --inpackage, etc., work.

Current Workaround

I'm aware that I can use a .mockery.yml config file with the packages section to specify directories:

packages:
  internal/path/:
    config:
      all: true
      inpackage: true

However, this significantly changes the workflow, especially for projects with many directories that need mock generation (I have 99+ usages of mockery --dir across my makefiles).

Questions

  1. Is the --dir flag intentionally removed in v3, or is this a bug?
  2. If intentionally removed, should the documentation be updated to clarify which parameters are available as CLI flags?
  3. Is there a recommended migration path for projects heavily relying on the --dir flag beyond converting everything to YAML config?

Environment

  • mockery version: v3.x (please specify your exact version)
  • Operating System: macOS (darwin 24.6.0)
  • Go version: go1.25.2 darwin/arm64

Additional Context

The migration from v2 to v3 would be much smoother if either:

  • The --dir flag is restored/fixed in v3, or
  • Clear migration documentation is provided explaining the new approach and why --dir is no longer supported

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