Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

66 lines
1.3KB

  1. #pragma once
  2. #include "./fs.hpp"
  3. #include "./glob.hpp"
  4. #include <json5/data.hpp>
  5. #include <optional>
  6. #include <variant>
  7. namespace dds {
  8. struct fs_transformation {
  9. struct copy_move_base {
  10. fs::path from;
  11. fs::path to;
  12. int strip_components = 0;
  13. std::vector<dds::glob> include;
  14. std::vector<dds::glob> exclude;
  15. };
  16. struct copy : copy_move_base {};
  17. struct move : copy_move_base {};
  18. struct remove {
  19. fs::path path;
  20. std::vector<dds::glob> only_matching;
  21. };
  22. struct write {
  23. fs::path path;
  24. std::string content;
  25. };
  26. struct one_edit {
  27. int line = 0;
  28. std::string content;
  29. enum kind_t {
  30. delete_,
  31. insert,
  32. } kind
  33. = delete_;
  34. };
  35. struct edit {
  36. fs::path path;
  37. std::vector<one_edit> edits;
  38. };
  39. std::optional<struct copy> copy;
  40. std::optional<struct move> move;
  41. std::optional<struct remove> remove;
  42. std::optional<struct write> write;
  43. std::optional<struct edit> edit;
  44. void apply_to(path_ref root) const;
  45. static fs_transformation from_json(const json5::data&);
  46. std::string as_json() const noexcept;
  47. };
  48. } // namespace dds