Skip to content
New issue

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

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

Already on GitHub? # to your account

Move more of cmd into public API #116

Closed
earthboundkid opened this issue Jan 6, 2017 · 4 comments
Closed

Move more of cmd into public API #116

earthboundkid opened this issue Jan 6, 2017 · 4 comments

Comments

@earthboundkid
Copy link
Contributor

I use godo to manage the asset pipeline for my blog. I want to add in minify, and I can do so by just invoking minify as an external binary, but it would be slightly more efficient if I could just import it as a Go package and do something like minifycli.Invoke("-r", "public"). That would require changing it so that the main package is basically only getting the command line options from os and everything else was done in an importable package.

@omeid
Copy link

omeid commented Jan 7, 2017

It is already doable and I use minfi with gonzo, see go-gonzo/html.

@tdewolff
Copy link
Owner

tdewolff commented Jan 9, 2017

This sounds like a very specific usecase, but as omeid said, wouldn't it be fairly trivial to implement it yourself? I suppose godo already supports recursiveness and file watching, you only need to minify a single file at a time (akin to the implementation in go-gonzo/html), correct me if I'm wrong though...

@earthboundkid
Copy link
Contributor Author

It's definitely a niche need and doable without a public command package, but you end up mostly just reinventing the wheel. The simplest way is just to copy-paste from the existing package main and then cut out all the parts you don't need, but it's a bit verbose. Nate Finch wrote a good blog post on ways of laying out your packages: https://npf.io/2016/10/reusable-commands/ . Obviously, it's your project, so just take it as a friendly suggestion. If it's interesting to you, I can work on a PR; if it's not, I can just work around it for myself.

@tdewolff
Copy link
Owner

tdewolff commented Apr 14, 2019

I don't think I will pick this up any time soon, so I'll close the issue for now. Ideally the minify cmd would be refactored at some point, but this will probably happen whenever I write a similar tool and separate the mutual code. Until then this has little priority.

I've added this to #234 though.

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

No branches or pull requests

3 participants