Page MenuHomeWildfire Games

Add a -help option
Needs RevisionPublic

Authored by linkmauve on Nov 19 2019, 10:03 PM.

Details

Reviewers
JoshuaJB
Summary

The help.h file is generated by premake in the source/ directory, but shouldn’t get committed there.

Test Plan

Run pyrogenesis -help, pyrogenesis --help and check that they print the help.
Run pyrogenesis and check that it doesn’t.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

linkmauve created this revision.Nov 19 2019, 10:03 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1121/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/605/display/redirect

linkmauve updated this revision to Diff 10359.Nov 19 2019, 10:10 PM

Added myself to the credits, and removed the .gitignore change as it doesn’t seem to exist on svn…

elexis added a subscriber: elexis.Nov 20 2019, 11:52 AM

Writing C++ code in premake sounds problematic, why not load the file in C++ directly? It seems like it'd be there even in the released version. On the other hand also seems unexpected that C++ code depends on a readme file?

Notice that we have a copy of this readme fle in Gamesetup.cpp L1196 already, it was proposed to remove the duplication before.

Perhaps one could have a Readme.cpp with the string and perhaps that could be written to the readme.txt file on demand (whenever soeone updates the file) and shown when the --help command is ran?

Then again that sounds like homecrafted version for a problem that has been solved in more general ways already.

Wouldn't a Manpage be more conventional? Don't linux distributions provide them already?

https://manpages.debian.org/stretch/0ad/0ad.6.en.html

Then one only needs to type man 0ad and it should show up, without changing any code.

JoshuaJB requested changes to this revision.Dec 1 2019, 11:53 PM
JoshuaJB added a subscriber: JoshuaJB.

I think this is okay. While a build-time copy isn't perfect, having a binaries' help text rely on an external file seems equivalently undesirable. A help text should always work in my opinion.

I just request that you also try to have Gamesetup.cpp use this API. I'd say it's up to you on if you want to swap things around such that the cpp file is the master copy which is copied to the system dir at build-time. Maybe not since text blocks in cpp files are harder to edit?

This revision now requires changes to proceed.Dec 1 2019, 11:53 PM
Stan added a subscriber: Stan.Dec 2 2019, 7:47 AM

Just for the record, only debian seems to provide a man command.

In D2432#102349, @Stan wrote:

Just for the record, only debian seems to provide a man command.

I'm not sure what you mean by this. Every distro I've ever used provides a man command. I think for some people, it's a matter of preference. Some would rather use man and some find "--help" perfectly adequate. help2man could be used to generate a man page during the run of update-workspaces.sh. Another option would be to not worry about a man page and only decide to add one if there's actually requests by users in the future.

But wouldn't it be easier to extract strings for translation if the strings were in the code itself? Since the goal is to have the game fully translated, wouldn't you want the help output translated as well? po4a can translate documents, but I don't think it'd be desirable to use that, or add it, while you already have a translation system in place.

Stan added a comment.Sep 27 2021, 8:28 PM

I mean that debian provides or used to provide a man page for 0 A.D. while some other distributions do not :).

Well we already extract strings from txt files (e.g tips) but I'm not sur the localisation is loaded that early. It could be though I suppose.

Well, I guess I'm repeating myself a bit... a man page can be a bitch to maintain. I suggest implementing a parser like C's getopt or https://theboostcpplibraries.com/boost.program_options , and using help2man to generate a man page (which can be at least customized a little with a template).

andy5995 added a comment.EditedSep 2 2022, 8:52 PM

And if a decision were made, I'd help implement it. This is an example of how I implemented it on rmw https://github.com/theimpossibleastronaut/rmw/blob/master/src/parse_cli_options.c

Though that was with no one else around to discuss it so I'd be open to variadic improvements ;)