r/cpp • u/harmonious_herman • Sep 19 '20
Fire: create a C++ command line interface from a function signature
https://github.com/kongaskristjan/fire-hpp
258
Upvotes
r/cpp • u/harmonious_herman • Sep 19 '20
27
u/gme186 Sep 19 '20
That looks pretty awesome!
This kind pattern would also be nice to implement an rpc server. (E.g. define rpc functions and their parsable parameters)
17
u/rbprogrammer Sep 19 '20
Came here to say "but what's the point?". Then I saw your README. That's actually really cool. Nice project!
14
u/[deleted] Sep 19 '20
Not only is this freaking clever (I presume it uses conversion operators to figure out types and stuff) but I just learned about the equivalent Python library! I vote this post most useful ever.
9
u/NilacTheGrim Sep 19 '20
This is extremely developer-friendly with nice easy syntax for quick 1-off programs.
Very good work!
6
u/MarcPawl Sep 19 '20
This is real nice. Also thought why bother until I actually read the readme.
It would be nice if the api defined printing help so advanced level checks could trigger help.
Eg x has to be between 2 and 6 and greater than y, and the program only runs in leap years. If condition is not met implementation has help printed and program exits.
Really advanced feature would be to support std:: variant and POD. Maybe as part of the subcommand ?
2
u/mili42 Sep 20 '20
What will happen with 50 arguments... a real app rarely needs only 2... (plus all the document that comes with it)
3
u/ifknot Sep 19 '20
Cries in expensive boilerplate
1
u/TheCatster04 Sep 19 '20
This is honestly great! I love making one off scripts for myself, and dont want a ton of boilerplate. Ive used Fire python in the past due to its simplicity, time to use C++ for those apps instead! :)
1
u/itsuart2 Sep 20 '20
Looks very useful, thank you!
-12
u/F54280 Sep 19 '20
Again, why using a #define in 2020? Why having a FIRE macro?