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

Feature request: allow to retain some empty lines #152

Closed
doublethink13 opened this issue Nov 4, 2023 · 5 comments · Fixed by #159
Closed

Feature request: allow to retain some empty lines #152

doublethink13 opened this issue Nov 4, 2023 · 5 comments · Fixed by #159

Comments

@doublethink13
Copy link

Imagine I have this file:

---
# https://taskfile.dev/styleguide/

version: "3"

env:
  PYTHON_VERSION: "3.11.2"

tasks:
  setup-python-interpreter:
    cmds:
      - pyenv install --skip-existing {{.PYTHON_VERSION}}
      - pyenv local {{.PYTHON_VERSION}}
    desc: uses pyenv to locally install python
  
  setup-venv:
    cmds:
      - python -m venv venv
    desc: sets up python venv

As far as I understand, I can do one of two things:

  • Either set retain_line_breaks to true, which means I could end up with extra lines even after formatting, for example:
---
# https://taskfile.dev/styleguide/





version: "3"

env:
  PYTHON_VERSION: "3.11.2"

tasks:
  setup-python-interpreter:
    cmds:
      - pyenv install --skip-existing {{.PYTHON_VERSION}}
      - pyenv local {{.PYTHON_VERSION}}
    desc: uses pyenv to locally install python



  setup-venv:
    cmds:
      - python -m venv venv
    desc: sets up python venv
  • Or I could set retain_line_breaks to false, which means I only end up with:
---
# https://taskfile.dev/styleguide/
version: "3"
env:
  PYTHON_VERSION: "3.11.2"
tasks:
  setup-python-interpreter:
    cmds:
      - pyenv install --skip-existing {{.PYTHON_VERSION}}
      - pyenv local {{.PYTHON_VERSION}}
    desc: uses pyenv to locally install python
  setup-venv:
    cmds:
      - python -m venv venv
    desc: sets up python venv

I would like to be able to set retain_line_breaks to a number, for example, 1, so that I can have a clear separation of one line, but never more, like the Taskfile style guide suggests, and I personally agree.

If this is something relevant I could try to have a look if you are accepting contributors 🙂

@braydonk
Copy link
Collaborator

braydonk commented Nov 4, 2023

Thanks for the feature request!

This might be doable; in internal/hotfix is where the hack for retaining line breaks is. It might work by just adding something that chomps continuous line breaks down to some minimum, so if there's 3 line breaks in a row then it only replaces it with one magic string.

If you are interested in contributing this I would be happy to accept it! If the PR contains the following things:

  • The functionality like I mentioned above
  • A new configuration parameter for this (can't mess with retain_line_breaks itself as that would be a breaking change; would need to be an additional option users can set)
  • An integration test, which would involve making a new folder testing this functionality with the new configuration option. The integration tests are new so you would be the first person other than me to use them, you can let me know if you run into any problems.

That would be great if you are willing to contribute this, and you can let me know if you run into any problems.

@doublethink13
Copy link
Author

Thanks for the reply and the information! I'll try to tackle this and I'll let you know 🙂

@braydonk
Copy link
Collaborator

braydonk commented Feb 4, 2024

Hey @doublethink13 I am going to implement this as part of v0.11.0 since I got a couple direct requests for it. Hopefully I don't steal your thunder if you had something going.

@doublethink13
Copy link
Author

hey @braydonk

sure go ahead 😉

i'm very sorry, life got in the way and eventually i forgot about this 🙁

@braydonk
Copy link
Collaborator

braydonk commented Feb 6, 2024

That's no problem, it happens. I should be getting this together before next week!

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

Successfully merging a pull request may close this issue.

2 participants