Skip to content

Commit

Permalink
aligned clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
SpectraL519 committed Feb 14, 2024
1 parent 6de2198 commit 4fb6df6
Show file tree
Hide file tree
Showing 18 changed files with 364 additions and 809 deletions.
62 changes: 17 additions & 45 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,76 +1,48 @@
---
Language: Cpp
Standard: Latest
Standard: c++20
DisableFormat: false


# General
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 80
ColumnLimit: 100
ContinuationIndentWidth: 4


# Alignment options
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
Enabled: false
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AlignTrailingComments: false

AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false

AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: true
BreakArrays: false
BreakAfterAttributes: Never
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
Expand Down Expand Up @@ -123,14 +95,14 @@ ShortNamespaceLines: 0

IndentAccessModifiers: false
AccessModifierOffset: -4
ConstructorInitializerIndentWidth: 4
ConstructorInitializerIndentWidth: 0
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
PackConstructorInitializers: NextLine
SeparateDefinitionBlocks: Leave
SeparateDefinitionBlocks: Always

IndentCaseBlocks: true
IndentCaseLabels: true
IndentCaseBlocks: false
IndentCaseLabels: false

IndentWrappedFunctionNames: false
LambdaBodyIndentation: Signature
Expand All @@ -154,7 +126,7 @@ SpaceAfterLogicalNot: true
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeParens: Custom
Expand All @@ -164,7 +136,7 @@ SpaceBeforeParensOptions:
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: false
AfterOverloadedOperator: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
Expand Down
1 change: 1 addition & 0 deletions change_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
### Version 1.1

* Added `change_log.md`
* Aligned the `.clang-format` configuration file and renamed `format/unix_like.sh` to `format/unix.sh`
17 changes: 7 additions & 10 deletions example/src/convert_numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
#include <bitset>
#include <iostream>


int main(int argc, char* argv[]) {
ap::argument_parser parser;
parser.program_name("convert numbers")
.program_description("shows the correct way of using dthe choices parameter")
.default_optional_arguments({ap::default_argument::optional::help});
.program_description("shows the correct way of using dthe choices parameter")
.default_optional_arguments({ ap::default_argument::optional::help });

parser.add_optional_argument<std::size_t>("number", "n")
.nargs(ap::nargs::any())
.help("positive integer value");
parser.add_optional_argument<std::size_t>("number", "n").nargs(ap::nargs::any()).help("positive integer value");
parser.add_optional_argument("base", "b")
.required()
.default_value("dec")
.choices({"bin", "dec", "hex"})
.help("output number format base");
.required()
.default_value("dec")
.choices({ "bin", "dec", "hex" })
.help("output number format base");

try {
parser.parse_args(argc, argv);
Expand Down
15 changes: 8 additions & 7 deletions example/src/merge_files.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#include <ap/argument_parser.hpp>

#include <iostream>
#include <fstream>
#include <iostream>
#include <sstream>


int main(int argc, char* argv[]) {
ap::argument_parser parser;
parser.program_name("merge files")
.program_description("shows the correct way of using default arguments")
.default_optional_arguments({ap::default_argument::optional::help,
ap::default_argument::optional::multi_input,
ap::default_argument::optional::output});
.program_description("shows the correct way of using default arguments")
.default_optional_arguments(
{ ap::default_argument::optional::help,
ap::default_argument::optional::multi_input,
ap::default_argument::optional::output }
);

try {
parser.parse_args(argc, argv);
Expand All @@ -30,7 +31,7 @@ int main(int argc, char* argv[]) {
const auto output_file_name = parser.value("output");

std::ofstream output_file(output_file_name);
if (!output_file.is_open())
if (! output_file.is_open())
throw std::runtime_error("Cannot open file: " + output_file_name);

for (const auto& input_file_name : input_file_name_list) {
Expand Down
11 changes: 4 additions & 7 deletions example/src/power.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#include <ap/argument_parser.hpp>

#include <iostream>
#include <cmath>
#include <iostream>

int main(int argc, char* argv[]) {
// create the parser class instance
ap::argument_parser parser;
parser.program_name("power calculator")
.program_description("calculates the value of an expression: base & exponent");
parser.program_name("power calculator").program_description("calculates the value of an expression: base & exponent");

// add arguments
parser.add_positional_argument<double>("base").help("the exponentation base value");
parser.add_optional_argument<int>("exponent", "e")
.nargs(ap::nargs::any())
.help("the exponent value");
parser.add_optional_argument<int>("exponent", "e").nargs(ap::nargs::any()).help("the exponent value");

parser.default_optional_arguments({ap::default_argument::optional::help});
parser.default_optional_arguments({ ap::default_argument::optional::help });

// parse command-line arguments
try {
Expand Down
14 changes: 4 additions & 10 deletions example/src/verbosity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
#include <cstdint>
#include <iostream>


namespace {

enum class verbosity_level : uint16_t {
low, mid, high
};
enum class verbosity_level : uint16_t { low, mid, high };

std::istream& operator>>(std::istream& input, verbosity_level& v) {
uint16_t value;
Expand Down Expand Up @@ -53,16 +50,13 @@ void print_msg(const verbosity_level verbosity) {

} // namespace


int main(int argc, char* argv[]) {
ap::argument_parser parser;
parser
.program_name("verbosity level")
parser.program_name("verbosity level")
.program_description("shows the correct way of using enums as a parser argument type")
.default_optional_arguments({ap::default_argument::optional::help});
.default_optional_arguments({ ap::default_argument::optional::help });

parser
.add_optional_argument<verbosity_level>("verbosity_level", "v")
parser.add_optional_argument<verbosity_level>("verbosity_level", "v")
.default_value(verbosity_level::low)
.implicit_value(verbosity_level::mid)
.nargs(1);
Expand Down
File renamed without changes.
Loading

0 comments on commit 4fb6df6

Please sign in to comment.