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

Splitting q into a library and executable? #16

Closed
JeremyRand opened this issue Dec 4, 2018 · 5 comments
Closed

Splitting q into a library and executable? #16

JeremyRand opened this issue Dec 4, 2018 · 5 comments

Comments

@JeremyRand
Copy link
Contributor

The q example is really nice, and I've wanted to use similar logic in a few of my projects (so that my own code can stick to a nice high-level API for DNS queries without re-implementing lots of DNS logic), but unfortunately since all of the q code is in the main package, it can't be used as a library. My initial workaround was just to copy and paste the q code into my own projects and make changes as needed, but this doesn't exactly scale well.

Would a PR be accepted that splits q into a library (which has all the code except for the flag stuff and the stdout/stderr formatting, and renames main() to a public function that accepts the args that are currently handled by global flag variables) and an executable (which has all the flag and stdout/stderr formatting code and adds a simple main() function that calls the library using the flag global variables as args)?

(Alternatively, if a library that's similarly flexible and user-friendly as the q example is already exists, feel free to point me to that -- I looked around and couldn't find one.)

@miekg
Copy link
Owner

miekg commented Dec 4, 2018

If there are useful bits here they should probably move to https://github.com/miekg/dns/tree/master/dnsutil

What bits are useful?

@JeremyRand
Copy link
Contributor Author

Basically I'd like an API that's equivalent to the command-line API in q, but as a Go function rather than a command-line tool, with function args instead of command-line flags, and with machine-readable return values instead of stdout/stderr output.

@miekg
Copy link
Owner

miekg commented Dec 5, 2018 via email

@JeremyRand
Copy link
Contributor Author

Okay. I guess I'll look into making a library fork of q, then. That's why it's open-source after all. :)

@JeremyRand
Copy link
Contributor Author

For anyone curious who's running across this issue, I've created a library fork of q. https://github.com/namecoin/qlib Very rough around the edges, but works for my use cases.

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

No branches or pull requests

2 participants