
Create a fully functioning command line interface with 1.5 lines of code - vitaut
https://github.com/kongaskristjan/fire-hpp
======
bdcravens
I can also write a fully functioning web application in 1 line of code if I
exclude how big each dependency is.

~~~
brazzy
If you can actually do that, it reflects positively on your dependency's
ability to make simple cases short and easy. Many libraries and frameworks
actually don't.

That's what this is about.

------
butz
The example is clearly 9 lines long and included fire.hpp has 703 lines of
source code excluding comments.

~~~
giomasce
It also requires several megabytes of standard library, kernel, operating
system and compiler, but the point is that you don't have to write them.
That's why you use libraries.

------
femto113
If we're playing CLI golf why not use macros to make it even dryer?

    
    
        int fired_main(int x = fire::arg("-x"), int y = fire::arg("-y"))
    

could just be

    
    
        int fired_main(int fire_arg(x), int fire_arg(y))
    

with something like

    
    
        #define fire_arg(v) v = fire::arg("-"#v)
    

The C preprocessor is still the thing I miss most when working in any other
language.

------
giomasce
It's unfortunate you can't just write something like:

    
    
        FIRE(args) {
            // ...
        }
    

without the explicit registration step. Unfortunately in this case the macro
FIRE should first declare the fired function, then main, then defined the
fired function, and this would be problematic because the definition can't
have the default values for arguments again. I can't see a way around that.

------
Jare
Funny, jut a couple days ago I started using dotnet's
System.CommandLine.DragonFruit which is similar in design philosophy to this -
a main function with typed parameters and extra annotations. I would have
never thought about this type of approach, or if I did I likely would have
rejected it outright in favor of more typical classes / functions to do it,
but I admit it's convenient for a quick tool.

------
thiagocsf
This reminds me of Click for Python in that the CLI is built based on the
functions that describe the commands and arguments.

Click uses decorators though. I don’t know what the C++ equivalent could be.

------
x87678r
I'd love a good library to handle an interactive prompt and state machine. You
know press 1/2/3 for x/y/z etc. Java especially

------
ncmncm
Somebody should explain that std::endl instead of '\n' is pointless, verbose,
and also slow.

------
gumby
Nice. boost::program_options needs a rethink for modern c++

------
Kiro
What does 1.5 lines of code mean?

~~~
setr
I think 1 line to modify the function sig, and .5 to call the library

Its purely marketing math, I think.

~~~
delaaxe
I think it’s the opposite

~~~
tirpen
Neither alternative makes sense, so you are both correct.

------
popotamonga
Anything for C#?

