Sujet : Re: Useless Use Of Regexes
De : OFeem1987 (at) *nospam* teleworm.us (Chris Ahlstrom)
Groupes : comp.os.linux.miscDate : 29. Mar 2025, 16:40:49
Autres entêtes
Organisation : None
Message-ID : <vs94a2$1kobq$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : slrn/1.0.3 (Linux)
rbowman wrote this post while blinking in Morse code:
On Fri, 28 Mar 2025 11:42:37 -0400, Chris Ahlstrom wrote:
>
The getopt family is a pain in the ass. I wrote my own command-line
parsing,
though I do not use it in legacy apps.
>
I've never used getopt_long() but I find getopt() to be cleaner than DIY
parsing.
My parser accepts an array of option structures specifying the long name, the
character code (if any), the type of data represented by the option,
enabling/disabling of options, the default value, the current value,
a dirty flag, and a description. It generates color-coded help. It has
common built-in options for help and verbosity, for example. And of
course a number of test apps.
Options can be grouped into sections suitable for read/write from an INI-style
file, complete with descriptions of each section.
It's written in C++, but with a C interface also provided.
During my recent wrestling with getopt_long(), I noticed a couple other
features to cover.
I'm not claiming anyone other than I will ever want to use it :-)
-- The departing division general manager met a last time with his youngsuccessor and gave him three envelopes. "My predecessor did this for me,and I'll pass the tradition along to you," he said. "At the first signof trouble, open the first envelope. Any further difficulties, open thesecond envelope. Then, if problems continue, open the third envelope.
Good luck." The new manager returned to his office and tossed the envelopes
into a drawer.
Six months later, costs soared and earnings plummeted. Shaken, the
young man opened the first envelope, which said, "Blame it all on me."
The next day, he held a press conference and did just that. The
crisis passed.
Six months later, sales dropped precipitously. The beleaguered
manager opened the second envelope. It said, "Reorganize."
He held another press conference, announcing that the division
would be restructured. The crisis passed.
A year later, everything went wrong at once and the manager was
blamed for all of it. The harried executive closed his office door, sank
into his chair, and opened the third envelope.
"Prepare three envelopes..." it said.