-
Notifications
You must be signed in to change notification settings - Fork 9
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 API for version and date #31
base: master
Are you sure you want to change the base?
Conversation
I guess we're using this crate differently. I've intended for this crate to be used from build.rs files, statically, to generate man pages that can be distributed with a package. To my knowledge it's not possible to provide man pages as part of the binary. I'd love it if there were a way tho! I think it would be reasonable to default by default to the current date, and allow people to override it using |
Hmmm, please correct me if I'm wrong, but wouldn't that build process still result in the wrong current date most of the time? For example, if someone installs your package with That wouldn't happen if someone installs a pre-built binary, but that seems like it isn't a guarantee (though it would be better for more rust utilities to be packaged in various package repositories, it still seems inevitable that a lot will be installed with |
Here's an idea that I'd appreciate your thoughts on: We could have the date default to querying the crates.io API and getting the The reason this is appealing is to handle the On the other hand, this is starting to feel like a bit of over-engineering, so if you'd prefer to go a different route I'd definitely understand. |
I don't think this is feasible because of the amount of dependencies that would require pulling in would be non-trivial. In essence it means we now either need to compile A much more efficient solution that would work on both versions would be to use a macro or const fn that resolves at compile time containing the date the crate was compiled on. |
Agreed, that makes perfect sense.
Hmm, I'm still a bit confused about how you're imagining Am I missing something here? |
This only applies to |
Well, it doesn't just apply to
I'm a little worried that we're at risk of letting the perfect be the enemy of the good-enough here. I agree that, in an ideal world, developers would distribute their programs through OS package managers and those tools would take care of installing the man page in the appropriate location/users wouldn't be compiling from source that often. However, I think we're currently very far from that ideal world crates.io lists 616 crates in the "Command Line Utilities" category, and my sense is that the vast majority of them are (currently) available primarily through So, as much as I'd like everyone to install with package managers—and plan to contribute to projects that make that easier—my view is that we should build Just my 2¢, though, and I'm happy to work on a PR implementing the other approach if that's the direction you want to go with the crate. (One final note, though—even if a program is distributed through a package manager, it's sometimes (often?) packaged by someone other than the developer. In that case, the third-party packager would compile the source code, and that could take place significantly after the developer last edited the code. If the date in the man page updates on every compilation, then the man page would reflect when the program was last packaged, not when it was last updated.) |
This PR adds the API for version and date as discussed in #26. Because the current date would be the date that the man page is generated (which might be much later than the date it was authored given that the docs contemplate runtime generation of the man page) this PR accepts the date as a user-specified string.
As noted in the comments, the code is slightly less elegant than would be ideal because the roff-rs API is not designed to include version and date info in the .TH element (which is where it needs to be placed). I plan to make a PR to that crate eventually but wanted
man
to have this functionality in the meantime.