1
0

deprecation-warning.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Warns users that this filename was deprecated, and provides a link for more information.
  2. #include <cstdio>
  3. #include <string>
  4. #include <unordered_map>
  5. // Main
  6. int main(int argc, char** argv) {
  7. std::string filename = "main";
  8. if (argc >= 1) {
  9. filename = argv[0];
  10. }
  11. // Get only the program name from the full path
  12. auto pos = filename.find_last_of("/\\");
  13. if (pos != std::string::npos) {
  14. filename = filename.substr(pos+1);
  15. }
  16. // Append "llama-" to the beginning of filename to get the replacemnt filename
  17. auto replacement_filename = "llama-" + filename;
  18. // The exception is if the filename is "main", then our replacement filename is "llama-cli"
  19. if (filename == "main") {
  20. replacement_filename = "llama-cli";
  21. }
  22. fprintf(stdout, "\n");
  23. fprintf(stdout, "WARNING: The binary '%s' is deprecated.\n", filename.c_str());
  24. fprintf(stdout, " Please use '%s' instead.\n", replacement_filename.c_str());
  25. fprintf(stdout, " See https://github.com/ggerganov/llama.cpp/tree/master/examples/deprecation-warning/README.md for more information.\n");
  26. fprintf(stdout, "\n");
  27. return EXIT_FAILURE;
  28. }