1 #ifndef PROJECT_INFO_H_
2 #define PROJECT_INFO_H_
3 
4 #include <thread>
5 
6 #include "GitInfo.h"
7 #include "Parser.h"
8 #include "Timer.h"
9 #include "WatchList.h"
10 
11 struct InfoToTrack
12 {
13 	Name name;
14 	Title title;
15 	Path templatePath;
16 	std::string contExt, outputExt;
17 
InfoToTrackInfoToTrack18 	InfoToTrack(const Name &inName,
19 	            const Title &inTitle,
20 	            const Path &inTemplatePath,
21 	            const std::string& cExt,
22 	            const std::string& oExt)
23 	{
24 		name = inName;
25 		title = inTitle;
26 		templatePath = inTemplatePath;
27 		contExt = cExt;
28 		outputExt = oExt;
29 	}
30 };
31 
32 int create_default_html_template(const Path& templatePath);
33 int create_blank_template(const Path& templatePath);
34 int create_config_file(const Path& configPath,
35                        const std::string& outputExt,
36                        bool global);
37 bool upgradeProject();
38 
39 struct ProjectInfo
40 {
41 	Directory contentDir,
42 	          outputDir;
43 	bool backupScripts, lolcatDefault;
44 	int buildThreads, paginateThreads, incrMode;
45 	std::string contentExt,
46 	            outputExt,
47 	            scriptExt,
48 	            terminal,
49 	            lolcatCmd,
50 	            unixTextEditor,
51 	            winTextEditor,
52 	            rootBranch,
53 	            outputBranch;
54 	Path defaultTemplate;
55 	std::set<TrackedInfo> trackedAll;
56 	std::mutex os_mtx3; //should this be removed?
57 
58 	int open(const bool& addMsg);
59 	int open_config(const Path& configPath, const bool& global, const bool& addMsg);
60 	int open_global_config(const bool& addMsg);
61 	int open_local_config(const bool& addMsg);
62 	int open_tracking(const bool& addMsg);
63 
64 	Path execrc_path(const std::string& exec, const std::string& execrc_ext);
65 	Path execrc_path(const std::string& exec, const char& execrc_ext);
66 
67 	int save_config(const std::string& configPathStr, const bool& global);
68 	int save_global_config();
69 	int save_local_config();
70 	int save_tracking();
71 
72 	TrackedInfo make_info(const Name& name);
73 	TrackedInfo make_info(const Name& name, const Title& title);
74 	TrackedInfo make_info(const Name& name,
75 	                      const Title& title,
76 	                      const Path& templatePath);
77 	TrackedInfo get_info(const Name& name);
78 	int info(const std::vector<Name>& names);
79 	int info_all();
80 	int info_watching();
81 	int info_tracking();
82 	int info_names();
83 
84 	int set_incr_mode(const std::string& modeStr);
85 	int remove_hash_files();
86 
87 	std::string get_ext(const TrackedInfo& trackedInfo,
88 	                    const std::string& extType);
89 	std::string get_cont_ext(const TrackedInfo& trackedInfo);
90 	std::string get_output_ext(const TrackedInfo& trackedInfo);
91 	std::string get_script_ext(const TrackedInfo& trackedInfo);
92 
93 	bool tracking(const TrackedInfo& trackedInfo);
94 	bool tracking(const Name& name);
95 	int track(const Name& name,
96 	          const Title& title,
97 	          const Path& templatePath);
98 	int track_from_file(const std::string& filePath);
99 	int track_dir(const Path& dirPath,
100 	              const std::string& cExt,
101 	              const Path& templatePath,
102 	              const std::string& oExt);
103 	int track(const std::vector<InfoToTrack>& toTrack);
104 	int track(const Name& name,
105 	          const Title& title,
106 	          const Path& templatePath,
107 	          const std::string& cExt,
108 	          const std::string& oExt);
109 	int untrack(const Name& nameToUntrack);
110 	int untrack(const std::vector<Name>& namesToUntrack);
111 	int untrack_from_file(const std::string& filePath);
112 	int untrack_dir(const Path& dirPath, const std::string& cExt);
113 	int rm_from_file(const std::string& filePath);
114 	int rm_dir(const Path& dirPath, const std::string& cExt);
115 	int rm(const Name& nameToRemove);
116 	int rm(const std::vector<Name>& namesToRemove);
117 	int mv(const Name& oldName, const Name& newName);
118 	int cp(const Name& trackedName, const Name& newName);
119 
120 	int new_title(const Name& name, const Title& newTitle);
121 	int new_template(const Path& newTemplatePath);
122 	int new_template(const Name& name, const Path& newTemplatePath);
123 	int new_output_dir(const Directory& newOutputDir);
124 	int new_content_dir(const Directory& newContDir);
125 	int new_content_ext(const std::string& newExt);
126 	int new_content_ext(const Name& name, const std::string& newExt);
127 	int new_output_ext(const std::string& newExt);
128 	int new_output_ext(const Name& name, const std::string& newExt);
129 	int new_script_ext(const std::string& newExt);
130 	int new_script_ext(const Name& name, const std::string& newExt);
131 
132 	int no_build_threads(int noThreads);
133 	int no_paginate_threads(int noThreads);
134 
135 	int check_watch_dirs();
136 
137 
138 	int build_untracked(std::ostream& os,
139 	                    const int& addBuildStatus,
140 	                    const std::set<TrackedInfo> infoToBuild);
141 	int build_names(std::ostream& os,
142 	                const int& addBuildStatus,
143 	                const std::vector<Name>& namesToBuild);
144 	int build_all(std::ostream& os, const int& addBuildStatus);
145 	int build_updated(std::ostream& os,
146 	                  const int& addBuildStatus,
147 	                  const bool& addExpl,
148 	                  const bool& basicOpt);
149 
150 	int status(std::ostream& os,
151 	           const int& addBuildStatus,
152 	           const bool& addExpl,
153 	           const bool& basicOpt);
154 };
155 
156 #endif //PROJECT_INFO_H_
157