A static site generator, written in C
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include "cms_util.h"
  4. #include "cms_log.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. if (initedPath == NULL)
  25. cms_log_panic("Memory allocation failed.");
  26. //Check if the .cmsinited file exists
  27. if (cms_util_file_exists(initedPath))
  28. cms_log_error("Directory already initiated.");
  29. //Create .cmsinited file
  30. cms_util_file_create(initedPath);
  31. }
  32. else if (strcmp(argv[1], "build") == 0) //Build
  33. {
  34. }
  35. }