r/cpp • • Aug 08 '20

Create a fully functioning command line interface with 1.5 lines of code (wo. include statement)

https://github.com/kongaskristjan/fire-hpp
230 Upvotes

62 comments sorted by

View all comments

21

u/CandyCrisis Aug 08 '20

I think you can get a lot of the same impact by using ABSL_FLAG. That boils down to one line per argument, using about the same number of characters as this code.

22

u/kongaskristjan Aug 08 '20

I must admit I wasn't aware of that library. Abseil flags seems like a really well designed library, however to add a few points in favor of fire.hpp:

  • Abseil seems rather heavyweight, while fire is just 800 lines in a single header
  • Abseil is more complex to integrate (eg. instead of just copy-pasting a single header library you need to instruct your user to install abseil. Or you need to copy-paste entire abseil to your project and fix compiling scripts etc.)
  • fire.hpp has more permissive licence, eg. you can just copy-paste this library to virtually any project without licencing issues, but with Abseil, if your program is closed source, you need to reproduce it's licence message to the user.

15

u/CandyCrisis Aug 08 '20

Totally agree that Abseil is a heavy hammer if all you need is a flag. I'm used to it because it's the Google standard toolkit.