Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document behaviour of lint cli args after -- #1581

Closed
collinsauve opened this issue Jun 4, 2024 · 3 comments
Closed

Document behaviour of lint cli args after -- #1581

collinsauve opened this issue Jun 4, 2024 · 3 comments

Comments

@collinsauve
Copy link

collinsauve commented Jun 4, 2024

Is your feature request related to a problem? Please describe.

We use pre-commit to automatically hook up a number of linters to our repository.

This tool sends the files that are to be commited as extra command-line arguments to redocly. By way of example, I use a pre-commit config like this:

      - id: my-api lint
        name: my-api lint
        entry:
          pnpm --package=@redocly/cli@1.14.0 dlx redocly lint my-api --config .redocly/config.yaml
        files: ^path\/to\/spec\/.*$
        language: system

Unfortunately due to the above pre-commit behaviour of sending the changed files, the actual command will be sent like this:

pnpm --package=@redocly/cli@1.14.0 dlx redocly lint my-api --config .redocly/config.yaml path/to/spec/file-that-i-changed.yml

Redocly interprets that last argument as a config file.

I found a work-around wherein if I add a -- to the end of the command, Redocly lint ignores anything after it!

Describe the solution you'd like

Pretty simply: Can you confirm that is indeed the expected and supported behaviour, or am I doing some spacebar heating? If it is supported, can it be called out in the docs?

Describe alternatives you've considered

Possibly could wrap it in my own shell script that throws away args.

Additional context

If the above is not clear, I'd be happy to provide a minimum reproduction by way of a small example repository.

@tatomyr
Copy link
Contributor

tatomyr commented Jun 10, 2024

Hi @collinsauve! The behaviour is not specific to Redocly CLI, it's how yargs (which is used as the arguments processor here) handles the input. I'm not sure we need to document that though, since the behaviour is pretty common.

@collinsauve
Copy link
Author

collinsauve commented Jun 10, 2024

Thanks for the confirmation that this is expected behavior. My primary concern was that I was relying on something unsupported.

Unfortunately I also don't see this in yargs docs. I used this only because, as you say it is a common pattern. Not going to push too hard on getting it documented now that it is confirmed here.

Thank you!

@lornajane
Copy link
Collaborator

Thanks @collinsauve I think your usage is the right way to use the -- command. I'm going to close this issue since it's both familiar and also from an upstream repository, so I don't think there's further action for us to take.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants