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

Add a strip comments flag that will remove all comments from the output #385

Closed
momoYB opened this issue Mar 5, 2020 · 5 comments
Closed
Milestone

Comments

@momoYB
Copy link

momoYB commented Mar 5, 2020

Is your feature request related to a problem? Please describe.
Add a strip comments flag, as it will help resolve some minor incompatible changes produced by the "keeping YAML comments" feature in YQ 3.X.X

mikefarah commented 14 days ago
...
Failing a yaml.v3 fix - the only thing I can think of is adding a strip comments flag that will remove all the comments...

Describe the solution you'd like
If we have countries.yaml like:

country:
    name: USA
    # name: United States of America
    capital: Washington, D.C.
    monuments:
        - Statue of Liberty
        - Grand Canyon
        # - Giant Sequoia
        # - Washington Monument
        - Mount Rushmore
    # currency: USD

Currently, if we run the command:

yq r countries.yaml "country.monuments"

the output is:

- Statue of Liberty
- Grand Canyon
# - Giant Sequoia
# - Washington Monument
- Mount Rushmore

With strip comments flag like:

yq r countries.yaml --stripComments "country.monuments"

the wanted output should be:

- Statue of Liberty
- Grand Canyon
- Mount Rushmore
@mikefarah
Copy link
Owner

This would be a nice feature to add - I'll get to it when I have time (or someone raises a PR...)

@mikefarah mikefarah added this to the 3.2.2 milestone Apr 14, 2020
@summatix
Copy link

Has this been implemented yet?

@mikefarah
Copy link
Owner

@summatix
Copy link

Ah ok. I was looking at yq merge and couldn't find the option, but now I see it in yq read.

@igaskin
Copy link

igaskin commented Jul 15, 2021

For future travelers, updated link for v4.x: https://mikefarah.gitbook.io/yq/operators/comment-operators#remove-strip-all-comments

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

4 participants