MichalGniadek / klask

Automatically create GUI applications from clap3 apps
MIT License
376 stars 23 forks source link

CLI & GUI Compilation Targets #29

Closed Zeddicus414 closed 2 years ago

Zeddicus414 commented 2 years ago

When I make tools using Python's Gooey library, I usually end up wanting a CLI version for myself (and maybe other power-users) and then a GUI for everyone else in the office.

If it's possible to get both a CLI & GUI binary from the same source code, it would be helpful to have an example.

Is this easily possible with conditional compilation or some other method?

MichalGniadek commented 2 years ago

Hi! You can use cargo to make multiple binaries. So you could make one cargo project with a library that contains most of your code and then two small binaries, that either call the clap directly or use klask.

Zeddicus414 commented 2 years ago

Ahh, that makes tons of sense. I learned something today!

For anyone asking the same question, this SO question has a concise example: https://stackoverflow.com/questions/36604010/how-can-i-build-multiple-binaries-with-cargo

Thank you.

arifd commented 2 years ago

Hi @MichalGniadek, I thought somewhere it was planned, to be able to create a single binary where if no command line arguments are supplied, then the Klask GUI would appear, otherwise, args would get passed to Clap, is this feature still on the roadmap? Or did I just hallucinate this feature altogether?

MichalGniadek commented 2 years ago

Hi, basically, I tried doing it this way at the very beginning, but there were some problems. But many people have said that they would like this feature to be implemented, and I finally have some time (and motivation) so I'm probably going to work on this in the near future.