A static site generator, written in C
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

main.c 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include "cms_util.h"
  4. #include "cms_err.h"
  5. #include "cms_files.h"
  6. int main(int argc, char** argv)
  7. {
  8. if (argc < 2)
  9. {
  10. fprintf(stderr, "Usage: %s <init|build>\n", argv[0]);
  11. return 1;
  12. }
  13. if (strcmp(argv[1], "init") == 0) //Initiate directory
  14. {
  15. if (argc != 3)
  16. {
  17. fprintf(stderr, "Usage: %s init <directory>\n", argv[0]);
  18. return 1;
  19. }
  20. char* dirname = argv[2];
  21. //Get the path of .cmsinited, which tells us
  22. //whether or not the directory is already inited
  23. char* initedPath = cms_util_path_join(dirname, CMS_FILE_INITED);
  24. //Panic if the directory is already initiated
  25. if (cms_util_file_exists(initedPath))
  26. cms_err_panic(CMS_ERR_INITED, NULL);
  27. //Create .cmsinited file
  28. cms_util_file_create(initedPath);
  29. }
  30. else if (strcmp(argv[1], "build") == 0) //Build
  31. {
  32. char* dirname = argv[2];
  33. //Get the path of .cmsinited, which tells us
  34. //whether or not the directory is already inited
  35. char* initedPath = cms_util_path_join(dirname, CMS_FILE_INITED);
  36. //Panic if the directory isn't initiated
  37. if (!cms_util_file_exists(initedPath))
  38. cms_err_panic(CMS_ERR_NOTINITED, NULL);
  39. }
  40. }