ed-asriyan / lottie-converter

Converts Lottie Animations (.json / .lottie) and Telegram stickers (*.tgs) to GIF / PNG / APNG / WEBP / WEBM
https://t.me/tgtowabot
MIT License
795 stars 72 forks source link

Use `basename(argv[0])` in help function #63

Closed saltedcoffii closed 2 years ago

saltedcoffii commented 2 years ago

In the current main.cpp code, the help function calls the executable tgs-to-gif, which works great! until the executable is renamed, to, e.g., tgs-to-gif or tgs2gif, the latter being the seeminly defacto standard for simple conversion programs (e.g., apng2gif, dos2unix, help2man, etc.) This simple change allows the Usage line to display correctly when the binary is renamed or symlinked to another name.

Builds and works on Linux.

ed-asriyan commented 2 years ago

Hello! Thank you for the patch, but docker build -t tgs-to-gif . works with an error:

/application/main.cpp:33:35: error: 'basename' was not declared in this scope; did you mean 'rename'?
   33 |  argparse::ArgumentParser program(basename(argv[0]));
      |                                   ^~~~~~~~
      |                                   rename
make[2]: *** [CMakeFiles/tgs_to_gif.dir/build.make:76: CMakeFiles/tgs_to_gif.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/tgs_to_gif.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
saltedcoffii commented 2 years ago

Thank you I will look into this.

saltedcoffii commented 2 years ago

It appears as though the Dockerfile uses alpine linux, with musl libc. The basename(argv[0]) syntax is not supported by musl. I added the libgen.h header, which adds the basename function, however I'm still struggling to fix the argv part. Any and all help is welcome.

ed-asriyan commented 2 years ago

master-cpp has renamed to master previous master become master-nodejs

please, rebase and reopen the pull request to master

saltedcoffii commented 2 years ago

I'm not going to reopen this because the .sh scripts can be renamed or symlinked and respect their new names. Thank you!