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: Flatten lists prior to passing to plugins so that yaml anchors can be used #122

Closed
dsifford opened this issue May 1, 2017 · 2 comments

Comments

@dsifford
Copy link
Contributor

dsifford commented May 1, 2017

Hello,

Long time Dotbot user here. Thanks for your hard work on this!

My request is fairly simple. I'm in a situation where I'm jumping between a macbook and a linux machine and I'm using both dotbot-pacuar and dotbot-brew to maintain a list of my packages for both machines.

The lists contain, for the most part, the same exact packages with a few here and there differences.

Currently, there's no way to use reference anchors in the plugin yaml file so I have to write my package lists like this:

- pacaur:
  - package1
  - package2
  - package3
  - package4
  - package5
  - linux-specific1

- brew:
  - package1
  - package2
  - package3
  - package4
  - package5
  - mac-specific1
  - mac-specific2

As you can see, there's a lot of unnecesary repeats between both lists.

What I'd like to do instead is this:

- &common
  - package1
  - package2
  - package3
  - package4
  - package5

- pacaur:
  - *common
  - linux-specific1

- brew:
  - *common
  - mac-specific1
  - mac-specific2

This almost works right now, but the hangup is that dotbot doesn't first flatten the lists prior to passing them to the plugins. So what the plugins end up getting is this:

- pacaur:
  -
    - package1
    - package2
    - package3
    - package4
    - package5
  - 
    - linux-specific1

- brew:
  - 
    - package1
    - package2
    - package3
    - package4
    - package5
  - 
    - mac-specific1
    - mac-specific2

Hope that makes sense. Thanks for considering! 😄

@anishathalye
Copy link
Owner

Hmm, this seems like it could be useful in the cases you specified, but I think it could break functionality elsewhere.

If we flattened lists before passing to plugins, what if there is a plugin that uses some kind of nested list structure? If we flattened lists, we'd break such plugins.

Would it be better to ask those plugin authors to implement the flattening in their plugin itself?

@dsifford
Copy link
Contributor Author

dsifford commented May 1, 2017

Thanks for the quick response 😄

Would it be better to ask those plugin authors to implement the flattening in their plugin itself?

Wasn't totally sure. Figured I'd start here and fan outward if it wasn't something you could add in. Definitely good points. Wasn't sure if there was a plugin spec that mandated yaml to be a maximum of one level deep. From the few plugins I peeked at, that looked like the common theme!

I'll forward the suggestion over to dotbot-pacaur and dotbot-brew tomorrow afternoon. Thanks again!

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

2 participants