1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! Define globally-shared constants.
pub mod error_messages {
//! Constants for error messages to be displayed.
/// An error occurred during [`std::process::Command::output`].
pub const CMD_EXECUTION_FAILURE: &str = "Failed to execute command";
/// An error occurred during HTTP body parsing.
pub const BODY_PARSING_ISSUE: &str =
"An error occurred during body parsing";
/// An error occurred while reading a file and converting it to a String
/// instance.
pub const FILE_READ_TO_STRING_FAILURE: &str =
"Failed to read expected output file";
/// Commas found in cli positional args.
pub const COMMAS_NOT_ALLOWED: &str =
"Commas are not allowed in template names";
/// An error occurred during an api call.
pub const API_CALL_FAILURE: &str =
"An error occurred during the API call: {error}";
/// A HTTP error 400 occurred during api call.
pub const HTTP_400: &str = "http status: 400";
/// User requested author infos but none is available.
pub const AUTHOR_INFOS_NOT_AVAILABLE: &str =
"Author information not available.";
/// User requested version infos but none is available.
pub const VERSION_INFOS_NOT_AVAILABLE: &str =
"Version information not available.";
}
pub mod help_messages {
//! Constants for help messages to be displayed.
/// Help message bound to [`crate::parser::Args::template_names`]
/// field (i.e. positional args).
pub const TEMPLATE_NAMES: &str =
"A non-empty list of gitignore template names";
/// Help message bound to [`crate::parser::Args::show_author`]
/// field (i.e. author option).
pub const AUTHOR: &str = "Print author";
/// Help message bound to [`crate::parser::Args::server_url`]
/// field (i.e. server url option).
pub const SERVER_URL: &str = "The gitignore template generator service url";
/// Help message bound to [`crate::parser::Args::show_help`]
/// field (i.e. help option).
pub const HELP: &str = "Print help";
/// Help message bound to [`crate::parser::Args::show_version`]
/// field (i.e. version option).
pub const VERSION: &str = "Print version";
/// Help message bound to [`crate::parser::Args::endpoint_uri`]
/// field (i.e. endpoint uri option).
pub const ENDPOINT_URI: &str =
"The gitignore template generator service endpoint uri";
}
pub mod cli_options {
//! Constants for short and long cli options specifier.
use crate::helper::CliOptionName;
/// Short and long specifier for author option.
///
/// **Value**: `-a --author`
pub const AUTHOR: CliOptionName = CliOptionName {
short: 'a',
long: "author",
};
/// Short and long specifier for server url option.
///
/// **Value**: `-s --server-url`
pub const SERVER_URL: CliOptionName = CliOptionName {
short: 's',
long: "server-url",
};
/// Short and long specifier for help option.
///
/// **Value**: `-h --help`
pub const HELP: CliOptionName = CliOptionName {
short: 'h',
long: "help",
};
/// Short and long specifier for version option.
///
/// **Value**: `-V --version`
pub const VERSION: CliOptionName = CliOptionName {
short: 'V',
long: "version",
};
/// Short and long specifier for endpoint uri option.
///
/// **Value**: `-e --endpoint-uri`
pub const ENDPOINT_URI: CliOptionName = CliOptionName {
short: 'e',
long: "endpoint-uri",
};
}
pub mod parser_infos {
//! Constants for general parser infos.
/// About text to be displayed when requesting help.
pub const ABOUT: &str = "Generate templates for .gitignore files";
}
pub mod exit_status {
//! Constants for script exit status code.
/// Exit status code for successful script execution.
pub const SUCCESS: i32 = 0;
/// Exit status code for generic script error.
pub const GENERIC: i32 = 2;
/// Exit status code for HTTP body parsing error.
pub const BODY_PARSING_ISSUE: i32 = 3;
}
pub mod template_generator {
//! Constants for template generator service.
/// Template generator service base URL.
pub const BASE_URL: &str = "https://www.toptal.com";
/// Template generator service URI.
///
/// Used in conjunction with [`BASE_URL`] to build full URL and make
/// API call.
pub const URI: &str = "/developers/gitignore/api";
}
pub mod path {
//! Constants for file or directory path.
/// Path to directory containing test output expectations.
pub const TEST_EXPECTATIONS: &str = "tests/expected";
}