Skip to content

Commit ae136e7

Browse files
committed
Add clang-format config and run it
The config is the same used by the loot repository.
1 parent 613fd7c commit ae136e7

File tree

3 files changed

+57
-16
lines changed

3 files changed

+57
-16
lines changed

.clang-format

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
5+
AccessModifierOffset: -2
6+
AllowAllParametersOfDeclarationOnNextLine: false
7+
AllowShortIfStatementsOnASingleLine: false
8+
BinPackArguments: false
9+
BinPackParameters: false
10+
BreakConstructorInitializers: AfterColon
11+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
12+
FixNamespaceComments: false
13+
SpaceAfterTemplateKeyword: false
14+
Standard: Cpp11
15+
...

src/main.cpp

+40-15
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424

2525
#include <cstring>
26+
#include <filesystem>
2627
#include <fstream>
2728
#include <iostream>
28-
#include <filesystem>
2929

3030
#include "loot/api.h"
3131
#include "version.h"
@@ -42,30 +42,54 @@ fs::path mockGameInstall() {
4242
return dataPath.parent_path();
4343
}
4444

45-
int main(int argc, char **argv) {
45+
int main(int argc, char** argv) {
4646
using loot::LootVersion;
4747
using loot::validator::Version;
4848
using std::cout;
4949
using std::endl;
5050

51-
// Print help text if -h, --help or invalid args are given (including no args).
52-
if (argc < 2 || argc > 3 || (strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
51+
// Print help text if -h, --help or invalid args are given (including no
52+
// args).
53+
if (argc < 2 || argc > 3 || (strcmp(argv[1], "-h") == 0) ||
54+
(strcmp(argv[1], "--help") == 0)) {
5355
cout << endl
54-
<< "Usage: metadata-validator <metadata file path> [<prelude file path>]" << endl << endl
55-
<< "Arguments:" << endl << endl
56-
<< " " << "<metadata file path>" << " " << "The metadata file to validate." << endl
57-
<< " " << "<prelude file path>" << " " << "The prelude metadata file to substitute in before validation (optional)." << endl
58-
<< " " << "-v, --version" << " " << "Prints version information for this utility." << endl
59-
<< " " << "-h, --help" << " " << "Prints this help text." << endl << endl;
56+
<< "Usage: metadata-validator <metadata file path> [<prelude file "
57+
"path>]"
58+
<< endl
59+
<< endl
60+
<< "Arguments:" << endl
61+
<< endl
62+
<< " "
63+
<< "<metadata file path>"
64+
<< " "
65+
<< "The metadata file to validate." << endl
66+
<< " "
67+
<< "<prelude file path>"
68+
<< " "
69+
<< "The prelude metadata file to substitute in before validation "
70+
"(optional)."
71+
<< endl
72+
<< " "
73+
<< "-v, --version"
74+
<< " "
75+
<< "Prints version information for this utility." << endl
76+
<< " "
77+
<< "-h, --help"
78+
<< " "
79+
<< "Prints this help text." << endl
80+
<< endl;
6081
return 1;
6182
}
6283

6384
// Print version info if -v or --version are given.
6485
if ((strcmp(argv[1], "-v") == 0) || (strcmp(argv[1], "--version") == 0)) {
65-
cout << endl << "LOOT Metadata Validator" << endl
66-
<< "v" << Version::string() << ", build revision " << Version::revision << endl
67-
<< "Using libloot v" << LootVersion::GetVersionString() << ", build revision " << LootVersion::revision
68-
<< endl << endl;
86+
cout << endl
87+
<< "LOOT Metadata Validator" << endl
88+
<< "v" << Version::string() << ", build revision " << Version::revision
89+
<< endl
90+
<< "Using libloot v" << LootVersion::GetVersionString()
91+
<< ", build revision " << LootVersion::revision << endl
92+
<< endl;
6993
return 0;
7094
}
7195

@@ -79,7 +103,8 @@ int main(int argc, char **argv) {
79103
cout << endl;
80104

81105
// Create a handle for any game at any path, it doesn't matter.
82-
auto handle = loot::CreateGameHandle(loot::GameType::tes4, gamePath.string(), gamePath.string());
106+
auto handle = loot::CreateGameHandle(
107+
loot::GameType::tes4, gamePath.string(), gamePath.string());
83108

84109
if (argc == 2) {
85110
handle->GetDatabase()->LoadLists(argv[1]);

src/version.cpp.in

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const unsigned int Version::patch = 0;
3232
const std::string Version::revision = "@GIT_COMMIT_STRING@";
3333

3434
std::string Version::string() {
35-
return std::to_string(major) + '.' + std::to_string(minor) + '.' + std::to_string(patch);
35+
return std::to_string(major) + '.' + std::to_string(minor) + '.' +
36+
std::to_string(patch);
3637
}
3738
}
3839
}

0 commit comments

Comments
 (0)