Skip to content

Commit 7e50d41

Browse files
committed
Addressed formatting issues
1 parent f0cd31e commit 7e50d41

3 files changed

Lines changed: 31 additions & 26 deletions

File tree

GridKit/Utilities/CliOptions/CliArgs.cpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ namespace GridKit
3333
return os;
3434
}
3535

36-
inline const std::string&
37-
typeString(const Argument& arg)
36+
inline const std::string& typeString(const Argument& arg)
3837
{
3938
static const std::string labelArray[] =
40-
{"STR", "REAL", "INT", "BOOL", "UNSPECIFIED"};
39+
{"STRING", "REAL", "INT", "BOOL", "UNSPECIFIED"};
4140
return labelArray[static_cast<int>(arg.type)];
4241
}
4342

@@ -225,20 +224,17 @@ namespace GridKit
225224
// This is stolen (and simplified) from Boost.ProgramOptions
226225
inline constexpr unsigned defaultLineLength = 80;
227226

228-
unsigned
229-
getLineLength()
227+
unsigned getLineLength()
230228
{
231229
return defaultLineLength;
232230
}
233231

234-
unsigned
235-
getMinHelpLength()
232+
unsigned getMinHelpLength()
236233
{
237234
return defaultLineLength / 2;
238235
}
239236

240-
std::string
241-
formatFirstColumn(const Argument& arg)
237+
std::string formatFirstColumn(const Argument& arg)
242238
{
243239
std::stringstream ss;
244240
ss << " ";
@@ -254,11 +250,9 @@ namespace GridKit
254250
return ss.str();
255251
}
256252

257-
unsigned
258-
getArgColumnWidth(
259-
const std::vector<Argument>& args,
260-
const unsigned lineLength,
261-
const unsigned minHelpLength)
253+
unsigned getArgColumnWidth(const std::vector<Argument>& args,
254+
const unsigned lineLength,
255+
const unsigned minHelpLength)
262256
{
263257
const unsigned startOfHelpColumn = lineLength - minHelpLength;
264258

@@ -279,14 +273,15 @@ namespace GridKit
279273
return width;
280274
}
281275

282-
void
283-
leftPad(std::ostream& os, unsigned width)
276+
void leftPad(std::ostream& os, unsigned width)
284277
{
285278
os << std::setfill(' ') << std::setw(width) << "";
286279
}
287280

288-
void
289-
printParagraph(std::ostream& os, std::string_view par, unsigned indent, unsigned lineLength)
281+
void printParagraph(std::ostream& os,
282+
std::string_view par,
283+
unsigned indent,
284+
unsigned lineLength)
290285
{
291286
// Through remainder of this function, 'lineLength' will be the length
292287
// available for characters, not including indent.
@@ -350,8 +345,10 @@ namespace GridKit
350345
}
351346
}
352347

353-
void
354-
printArgHelp(std::ostream& os, const std::string& desc, unsigned firstColWidth, unsigned lineLength)
348+
void printArgHelp(std::ostream& os,
349+
const std::string& desc,
350+
unsigned firstColWidth,
351+
unsigned lineLength)
355352
{
356353
// we need to use one char less per line to work correctly if actual
357354
// console has longer lines
@@ -376,8 +373,10 @@ namespace GridKit
376373
}
377374
}
378375

379-
void
380-
printArg(std::ostream& os, const Argument& arg, unsigned firstColWidth, unsigned lineLength)
376+
void printArg(std::ostream& os,
377+
const Argument& arg,
378+
unsigned firstColWidth,
379+
unsigned lineLength)
381380
{
382381
auto c1 = formatFirstColumn(arg);
383382
os << c1;
@@ -438,14 +437,19 @@ namespace GridKit
438437
return ss.str();
439438
}
440439

441-
void CliArgs::printHelp(std::ostream& os) const
440+
void CliArgs::printUsage(std::ostream& os) const
442441
{
443442
os << "Usage: " << app_name_;
444443
for (auto&& arg : table_)
445444
{
446445
os << " " << formatArgUsage(arg);
447446
}
448447
os << "\n\n";
448+
}
449+
450+
void CliArgs::printHelp(std::ostream& os) const
451+
{
452+
printUsage(os);
449453

450454
auto lineLength = getLineLength();
451455
auto minHelpLength = getMinHelpLength();

GridKit/Utilities/CliOptions/CliArgs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ namespace GridKit
139139

140140
void parseArgs(int argc, const char* argv[]);
141141

142+
void printUsage(std::ostream& os = std::cout) const;
142143
void printHelp(std::ostream& os = std::cout) const;
143144

144145
const ArgVector& operator[](const std::string& name) const

examples/PhasorDynamics/Tiny/ThreeBus/Basic/ThreeBusBasicJson.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ int main(int argc, const char* argv[])
3939
using namespace GridKit::Utilities;
4040
using namespace GridKit::Testing;
4141

42-
CliArgs args{{.name = {"--config", "-c"},
43-
.help = "JSON file describing the network",
42+
CliArgs args{{.name = {"--case", "-c"},
43+
.help = "JSON file describing the system configuration",
4444
.required = true},
4545

4646
{.name = {"--compare", "-r"},
@@ -101,7 +101,7 @@ int main(int argc, const char* argv[])
101101
sys.stopMonitor();
102102

103103
// Generate aggregate errors comparing variable output to reference solution
104-
TestStatus status{true};
104+
TestStatus status{__func__};
105105
if (!args["compare"].empty())
106106
{
107107
const auto& [out_file, ref_file] = args["compare"].as<std::string, 2>();

0 commit comments

Comments
 (0)