-8

I vote we re-open the following question, which has been closed for 9 years:

How to Parse Command Line Arguments in C++?

This question was closed as a duplicate, but the duplicate was also closed as off-topic. Currently this is the #1 link in search engines when searching for "C++ optparse", "C++ argument parsing", etc.

Other languages have similar threads that are not closed, for example:

I agree it could/should be closed if there is standard library support for argument parsing, but in the case of C/C++, there is no standard library for parsing arguments, so these lists on SO are a great way to see what the current possibilities are.

Anyway, I came up with my own solution that is not in the list that I think C++ devs would find useful, but there is nowhere I can add my answer that will have any visibility because the most visible ones are all closed.

21
  • Why not just ask a question asking how to parse arguments without a library? Feb 10, 2021 at 22:18
  • 1
    ... and answer that one yourself. Feb 10, 2021 at 22:19
  • Wouldn't that have a high risk of being closed as a duplicate? Also, the original question I linked isn't asking for a specific library, and indeed many of the answers are vanilla C++: stackoverflow.com/a/868894/2516916
    – Gillespie
    Feb 10, 2021 at 22:26
  • 2
    Good answers do not make a good question Feb 10, 2021 at 22:27
  • Ok, then let's edit the question so it is better phrased. I don't see how closing this question so more good answers can't be added is helpful to the C++ community.
    – Gillespie
    Feb 10, 2021 at 22:27
  • You have editing privileges, if you think you can edit the question to be on topic there's nothing really stopping you. And questions are closed because they're meant to be closed. Not because they're not necessarily helpful. Feb 10, 2021 at 22:29
  • 1
    "And questions are closed because they're meant to be closed. Not because they're not necessarily helpful." Ok, then why is the C one I linked to not closed even though it is the exact same question, just for a different language?
    – Gillespie
    Feb 10, 2021 at 22:29
  • 1
    A) Because its not asking for a library. B) Because not every question gets handled in the same way or by the same people Feb 10, 2021 at 22:30
  • So I guess what you meant to say earlier is "Questions are closed because the whims of the high rep people in different tags are different" not "questions are closed because they're meant to be closed"
    – Gillespie
    Feb 10, 2021 at 22:32
  • Also, the original question I linked was not closed for being off-topic, it was closed for being a duplicate of an off topic question, which I disagree with
    – Gillespie
    Feb 10, 2021 at 22:33
  • 3
    Questions are reopened because of the whims of lower rep people looking to post their answers on off topic questions /shrug you do you. I won't be voting to reopen. Feb 10, 2021 at 22:33
  • 2
    The C++ question you linked is way too broad. We will not be reopening it.
    – Cody Gray Mod
    Feb 10, 2021 at 23:21
  • 3
    These aren't the kinds of questions we allow on Stack Overflow, so we don't optimize them for future Googlers. Be wary of the "ideological consistency" argument; that's the one in favor of deleting the Q&A altogether.
    – Cody Gray Mod
    Feb 10, 2021 at 23:54
  • 2
    You drastically changed the meaning of the question, which invalidated many of the answers, yet still did not address the fundamentally too broad nature of the question. The C question you keep mentioning is asking a specific question about a specific block of code. Doesn't Makoto already address this in his answer? I didn't see the merit in repeating it in a comment.
    – Cody Gray Mod
    Feb 11, 2021 at 0:00
  • 2
    The "general case" that you think people care about are the types of questions that are unsuitable for Stack Overflow.
    – Cody Gray Mod
    Feb 11, 2021 at 0:20

2 Answers 2

-5

The question How to Parse Command Line Arguments in C++? is asking how to parse command line options. This is a reasonably scoped "How-to" question, and is not really a duplicate of the target What parameter parser libraries are there for C++? which is asking for library solutions (the target appears to be seeking recommendations, and should probably remain closed). I've reopened the "how-to" question.

Note that the comparison with the possibly similar C question is not really relevant, mostly because it's an old question. Things used to be very different back in the day, and questions that would be downvoted to oblivion, and insta-closed and insta-deleted today, were very well received, and have lots of views and upvotes.

I've reopened the C++ question on its merit, and not because of any possible connection with the C question, which may or may not be close-worthy.


A little bit of cleanup was needed.

The question says "best" which is a trigger for curators to close as opinion based. I've rephrased that part slightly.

The question also specifies a particular syntax, which seems unnecessary, so I've edited that to just be a suggested syntax, or an example of what command line options might look like.

The question also did have a line "Is there a library in STL to do this?", which is seeking Recommendations. I've removed this line, and added a link to the old target in the question body. I've also removed the old banner since that seems to stick around even when the question is reopened.

Importantly, there are also a number of answers (7/10) on this question that suggest external libraries:

These should be moved to the second question, i.e. the old target, and I've raised a flag asking for migration of those answers. Some of these suggestions are duplicated on the target, and so needn't be migrated (I've indicated which ones these are in the above list.


Similarly, there is an answer on the old target that isn't suggesting external libraries at all, and instead should be moved to this question:

I've raised a flag for migrating this answer as well.

13
  • I agree question body needed to be cleaned up and I also agree with your proposed answer moves. In the future I will try making edits to improve the question first before trying to get it re-opened.
    – Gillespie
    Feb 10, 2021 at 23:20
  • Hmm, this proposal doesn't really work. We can't selectively migrate answers all over the place. All we can do is merge one question into another, which merges everything from that question (answers, comments, the whole lot) to the other question, essentially combining them. What you've described here is much too complicated for our tooling.
    – Cody Gray Mod
    Feb 10, 2021 at 23:23
  • @CodyGray That's unfortunate. Are you saying that the question should be closed, or only that the migrations can't happen? If so, I guess the answers can stay where they are; I still think the question should remain open, even with the answers suggesting tools.
    – cigien
    Feb 10, 2021 at 23:25
  • 5
    The question is horribly broad and completely inappropriate to have open.
    – Cody Gray Mod
    Feb 10, 2021 at 23:25
  • @CodyGray Oh, very interesting. Seems perfectly reasonable to me. A simple solution could be written in 10-20 lines, as some of the answers have done.
    – cigien
    Feb 10, 2021 at 23:26
  • 4
    The length of the solution is not the only consideration.
    – Cody Gray Mod
    Feb 10, 2021 at 23:27
  • @CodyGray You think parsing command line options is too broad? If the question asked for a full fledged parser, with groups, and other bells and whistles, then yes, it would be too broad. As it stands, it's mostly asking how to split a string, with a little bit of additional stuff.
    – cigien
    Feb 10, 2021 at 23:29
  • 1
    That's not clear at all; it looks and reads to me like it's asking for a parser, and it is very obvious that was the intent of the asker.
    – Cody Gray Mod
    Feb 10, 2021 at 23:30
  • 1
    I merged the two together, keeping the one with more views and activity. But I'm pretty inclined to just delete the whole thing.
    – Cody Gray Mod
    Feb 10, 2021 at 23:30
  • Merging is pretty reasonable, though a bit of a blunt hammer here. My contention is that it can still be reasonably answered, and hence should be open. As to deleting it, it looks like that Q&A has plenty of value, both in terms of external links, views, and votes on the questions and answers. I thought you were against deleting value.
    – cigien
    Feb 10, 2021 at 23:32
  • 2
    Beaucoup duplicates here...cleaned up a bunch more. Not a lot of value in link-only answers. Most of this represents the worst of SO. Not too thrilled either that I have to come behind and try to fix actions that get taken within 1 hour of posting a Meta question, rather than actually discussing it.
    – Cody Gray Mod
    Feb 10, 2021 at 23:35
  • @CodyGray Thanks for the cleanup, it's much appreciated. Please delete all the link only answers, no issues with that. However, there are a number of answers that actually implement their own solutions, as well as answers that show how to use the external tools they link to. Are those reasonable to keep around, or would you be inclined to delete those as well?
    – cigien
    Feb 10, 2021 at 23:38
  • @CodyGray Actions? You mean action? You literally have to only press the "rollback" button to undo everything that I did. It hardly seems like the changes I made (while taking me a bit of time to do) were too much work to fix. Please let me know if I overstepped my bounds in any way by editing a question, and reopening it with my hammer because I thought it should be open.
    – cigien
    Feb 10, 2021 at 23:39
6

Those questions you're comparing couldn't be more different if you tried.

The C question is very specific and has the hallmarks of a question we like:

  • Specific domain (command line parsing)
  • Narrow focus (only their specific issue with their implementation)
  • Their own code
  • Experts could grok this and contribute at a reasonable level

The C++ question - in spite of its internet fame - has the hallmarks of a question we don't like:

  • Asks for a library (Q&A is hard; let's go shopping
  • Looks for "best" way (trigger word since there is no "best" anything, but there are some reasonable approaches)
  • Open ended (anyone could interpret this any way they wish and not necessarily be wrong)

So no, I don't think it should be reopened. It's an argument for permanently locking the question, but reopening is definitely off the table.

12
  • 3
    "Asks for a library" Does it though? I believe the exact quote is "Is there a library in STL to do this?" Meaning "Is there a way to do this with C++ standard library"? Also, the answers in the question are amazing, I just don't get the culture of closing the question so no more answers can be added instead of improving the question. Just delete "best" and "library" from the question body and suddenly it won't trigger you anymore.
    – Gillespie
    Feb 10, 2021 at 23:02
  • 5
    I think we can all agree the answers are useful and the title of the question is extremely useful, as evidenced by the upvotes on them. So I think it would be more constructive for the community if we were to edit/rephrase the question body to give it the "hallmarks of a question we like" rather than just close it so it's readonly and nobody can contribute other useful answers that are a decade newer.
    – Gillespie
    Feb 10, 2021 at 23:09
  • @Gillespie: It's the same effect. "Is there code in X language to do Y" is essentially the spirit of the question, which applies equally if you're using an outside library or if you're using the same standard language library. Someone asking us that question is asking us to read the documentation on their behalf and give them the exact thing they're looking for, and they get ultimate veto power over whether or not it's "right" since they may not think that the answer is copy-pasteable enough.
    – Makoto
    Feb 12, 2021 at 17:05
  • That's literally the main reason StackOverflow is valuable. It's a repository of code snippets that do useful things that saves you a ton of time reading man pages and rolling your own solutions. "How do I [create an ISO 8601 timestamp] in [language]" (for example) is a super useful SO question because that's a common snippet of code many developers are going to need in nearly every language.
    – Gillespie
    Feb 12, 2021 at 20:33
  • @Gillespie: I think you gravely misunderstand the goal. Our goal isn't to be a code snippet repository. It's to be widely useful for a lot of applications that can stand the test of time, and we have created convention and policy to help with that. Something that is useful or widely applicable to everyone should be able to fit in with the policies that we have, and the vast majority of it has. When we talk about exceptions then we have to evaluate the exceptional circumstance on its merits. I've done that with this question, and...it doesn't even come close.
    – Makoto
    Feb 12, 2021 at 21:07
  • @Gillespie: I think the main thing that you should rejoice in is that at a minimum, the question is now frozen. This means that, while it won't have any additions to it (since it'll just turn into a whole smorgasbord of "use this" or "use this" which is absolutely not what we want to have), the question will still be around for those who can still glean some value out of it.
    – Makoto
    Feb 12, 2021 at 21:10
  • IMO, it doesn't matter what the stated goal of SO is. If SO needs to pivot/evolve its stated goals in order to better meet the needs of developers, it should do so. I as a C/C++/Python/JS developer want SO to mainly be a searchable, sortable, and highly discoverable snippet repository (with some extra words to explain caveats and context as needed). I would wager the vast majority of SO users feel the same, and am willing to bet money on it. If we added it to the annual survey we would know for sure.
    – Gillespie
    Feb 12, 2021 at 22:44
  • 1
    To be clear, I don't want SO to be a collection of extremely specific questions that only apply to that one specific scenario. For me, the more devs a question helps, the better. "How do I split a string given a delimiter in C++?" is an extremely useful question, even though it is broad enough that there might be many different approaches to solving it. No offense, but I think you are a bit out of touch with the average SO user. Your rep indicates you are a top .16% power user which likely means you use SO very differently from most registered users (not to mention the silent majority)
    – Gillespie
    Feb 12, 2021 at 22:45
  • I'll agree to disagree and take this discussion no further @Gillespie.
    – Makoto
    Feb 12, 2021 at 22:46
  • Sure. I'm just pointing out that high rep users on SO are in a bubble just as much as any other community. If you visit other fora where developers frequent like Hacker News, you'll find many people, including CEOs of tech companies and prominent GitHub project maintainers, don't share your view on SO. news.ycombinator.com/item?id=9063356
    – Gillespie
    Feb 12, 2021 at 23:03
  • 1
    @Gillespie: You do know that Shog9 was an employee up until last year, right? And his perspective captured the situation pretty much perfectly, right? To be fair though I do share my view on Stack Overflow on outside media or other communities. They're burned by the inertia that is, well, we want questions to have specific things in them, and for whatever reason, others just think we're some kind of global help desk that'll go out of our way to help them at every beckon and call. No wonder there's friction.
    – Makoto
    Feb 13, 2021 at 0:04
  • Well perhaps we've been in violent agreement this whole time then and are just quibbling about this particular case. jasode's comment resonated with me, but Shog9's response is reasonable as well. Anyway, I'll stop bugging you now.
    – Gillespie
    Feb 13, 2021 at 2:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .