gitignore_template_generator/
constant.rs1pub mod error_messages {
4 pub const CMD_EXECUTION_FAILURE: &str = "Failed to execute command";
8
9 pub const BODY_PARSING_ISSUE: &str = "An error occurred during body parsing";
11
12 pub const FILE_READ_TO_STRING_FAILURE: &str = "Failed to read expected output file";
15
16 pub const COMMAS_NOT_ALLOWED: &str = "Commas are not allowed in template names";
18
19 pub const API_CALL_FAILURE: &str = "An error occurred during the API call: {error}";
21
22 pub const HTTP_400: &str = "http status: 400";
24
25 pub const HTTP_404: &str = "http status: 404";
27
28 pub const AUTHOR_INFOS_NOT_AVAILABLE: &str = "Author information not available.";
30
31 pub const VERSION_INFOS_NOT_AVAILABLE: &str = "Version information not available.";
33
34 pub const WHITESPACES_NOT_ALLOWED: &str =
42 "Whitespace characters are not allowed in template names";
43
44 pub const INEXISTENT_TEMPLATE_NAMES: &str = "Following template names are not supported: {templates}.\nFor the list of available template names, try '--list'.";
46
47 pub const FAILED_U64_CONVERSION: &str = "Failed to convert to u64";
49
50 pub const TIMEOUT: &str = "timeout: global";
52
53 pub const INVALID_ENCODING: &str = "io: stream did not contain valid UTF-8";
55
56 pub const URI_WITHOUT_STARTING_SLASH: &str = "URIs must start a slash (/)";
58
59 pub const INVALID_URL: &str = "Value must be a valid URL";
61
62 pub const LOCAL_GENERATION: &str =
63 "An error occurred while generating template from local file system";
64
65 pub const LOCAL_LISTING: &str =
66 "An error occurred while listing templates from local file system";
67
68 pub const UNSUPPORTED_TEMPLATE: &str = "One or more provided template names are not supported\nTo enable robust template names check, retry with '--check'.\nFor the list of available template names, try '--list'.";
69
70 pub const READ_HOME_ENV_VAR: &str = "An error occurred when trying to read $HOME, which is required for local generation: {error}";
71}
72
73pub mod help_messages {
74 pub const TEMPLATE_NAMES: &str = "A non-empty list of gitignore template names";
79
80 pub const AUTHOR: &str = "Print author";
83
84 pub const SERVER_URL: &str = "The template manager url";
87
88 pub const HELP: &str = "Print help";
91
92 pub const VERSION: &str = "Print version";
95
96 pub const GENERATOR_URI: &str = "The template generator uri";
99
100 pub const LIST: &str = "List available templates";
103
104 pub const LISTER_URI: &str = "The template lister uri";
107
108 pub const CHECK: &str = "Enable robust template names check";
111
112 pub const TIMEOUT: &str = "The template generation and listing service calls timeout";
115
116 pub const TIMEOUT_UNIT: &str = "The timeout unit";
119}
120
121pub mod help_texts {
122 pub const NOTHING_TO_BE_PRINTED: &str = "Nothing to be printed";
123
124 pub const ENV_VAR_RESET: &str = "{name} env var was set to {value}. Resetting it...";
125 pub const ENV_VAR_REMOVAL_BEFORE: &str = "{name} is set. Removing it...";
126 pub const ENV_VAR_REMOVAL_AFTER: &str = "{name} env var wasn't set. Removing it...";
127
128 pub const RESET: &str = "Reset!";
129 pub const REMOVED: &str = "Removed!";
130
131 pub const TEST_CXT_DROPPED: &str = "Test context dropped!";
132 pub const TEST_CTX_CREATED: &str = "Test context created!";
133
134 pub const DEFAULT_TIMEOUT: &str = "{second}s/{millis}ms";
135}
136
137pub mod cli_options {
138 use crate::parser::CliOptionName;
141
142 pub const AUTHOR: CliOptionName = CliOptionName {
146 short: "a",
147 long: "author",
148 };
149
150 pub const SERVER_URL: CliOptionName = CliOptionName {
154 short: "s",
155 long: "server-url",
156 };
157
158 pub const HELP: CliOptionName = CliOptionName {
162 short: "h",
163 long: "help",
164 };
165
166 pub const VERSION: CliOptionName = CliOptionName {
170 short: "V",
171 long: "version",
172 };
173
174 pub const GENERATOR_URI: CliOptionName = CliOptionName {
178 short: "g",
179 long: "generator-uri",
180 };
181
182 pub const LIST: CliOptionName = CliOptionName {
186 short: "l",
187 long: "list",
188 };
189
190 pub const LISTER_URI: CliOptionName = CliOptionName {
194 short: "i",
195 long: "lister-uri",
196 };
197
198 pub const CHECK: CliOptionName = CliOptionName {
202 short: "c",
203 long: "check",
204 };
205
206 pub const TIMEOUT: CliOptionName = CliOptionName {
210 short: "t",
211 long: "timeout",
212 };
213
214 pub const TIMEOUT_UNIT: CliOptionName = CliOptionName {
218 short: "u",
219 long: "timeout-unit",
220 };
221}
222
223pub mod parser_infos {
224 pub const ABOUT: &str = "Generate templates for .gitignore files";
228}
229
230pub mod exit_status {
231 pub const SUCCESS: i32 = 0;
235
236 pub const GENERIC: i32 = 2;
238
239 pub const BODY_PARSING_ISSUE: i32 = 3;
241
242 pub const HTTP_CLIENT_ERROR: i32 = 4;
244}
245
246pub mod template_manager {
247 use crate::parser::TimeoutUnit;
250
251 pub const HOME_ENV_VAR: &str = "GITIGNORE_TEMPLATE_GENERATOR_HOME";
253
254 pub const DEFAULT_HOME: &str = ".gitignore_template_generator";
256
257 pub const DEFAULT_TEMPLATE_DIR: &str = "{home_path}/.gitignore_template_generator/templates";
258
259 pub const BASE_URL: &str = "https://www.toptal.com";
261
262 pub const GENERATOR_URI: &str = "/developers/gitignore/api";
267
268 pub const LISTER_URI: &str = "/developers/gitignore/api/list";
273
274 pub const TIMEOUT: &str = "5";
276
277 pub const TIMEOUT_MILLISECOND: &str = "5000";
279
280 pub const TIMEOUT_INT: u64 = 5;
282
283 pub const TIMEOUT_MILLISECOND_INT: u64 = 5000;
285
286 pub const TIMEOUT_UNIT: &str = "second";
288
289 pub const TIMEOUT_MILLISECOND_UNIT: &str = "millisecond";
291
292 pub const TIMEOUT_UNIT_ENUM: TimeoutUnit = TimeoutUnit::SECOND;
296}
297
298pub mod path {
299 pub const TEST_EXPECTATIONS: &str = "tests/expected";
303
304 pub const TEST_RESOURCES: &str = "tests/resources";
306}