diff --git a/.clang-format b/.clang-format index e2417d3..77c1c29 100644 --- a/.clang-format +++ b/.clang-format @@ -104,8 +104,8 @@ BraceWrapping: AfterObjCDeclaration: false AfterStruct: false AfterUnion: false - BeforeCatch: false - BeforeElse: false + BeforeCatch: true + BeforeElse: true BeforeLambdaBody: false BeforeWhile: false IndentBraces: false @@ -129,7 +129,7 @@ BreakBeforeCloseBracketIf: true BreakBeforeCloseBracketLoop: true BreakBeforeCloseBracketSwitch: true BreakBeforeConceptDeclarations: Always -BreakBeforeBraces: Attach +BreakBeforeBraces: Custom BreakBeforeInlineASMColon: OnlyMultiline BreakBeforeTemplateCloser: false BreakBeforeTernaryOperators: true @@ -175,7 +175,7 @@ IncludeCategories: IncludeIsMainRegex: '([-_](test|unittest))?$' IncludeIsMainSourceRegex: '' IndentAccessModifiers: false -IndentCaseBlocks: true +IndentCaseBlocks: false IndentCaseLabels: true IndentExportBlock: true IndentExternBlock: AfterExternBlock diff --git a/README.md b/README.md index d6449ae..95aac3b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # TODO: Write up ## Install -curl --proto '=https' --tlsv1.2 -sSf -L https://raw.githubusercontent.com/gojocli/gojo/refs/heads/main/install.sh | sh \ No newline at end of file +curl --proto '=https' --tlsv1.2 -sSf -L https://raw.githubusercontent.com/whuffman36/gojo/refs/heads/main/install/install.sh | sh \ No newline at end of file diff --git a/install/gojo-c-format b/install/gojo-c-format new file mode 100644 index 0000000..7d11ba5 --- /dev/null +++ b/install/gojo-c-format @@ -0,0 +1,330 @@ +--- +Language: C +AlignAfterOpenBracket: true +AccessModifierOffset: -1 +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: true + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + #AlignPPAndNotPP: true + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowBreakBeforeQtProperty: false +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AttributeMacros: +BinPackArguments: true +BinPackLongBracedList: true +BinPackParameters: BinPack +BitFieldColonSpacing: Both +BracedInitializerIndentWidth: -1 +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterOpenBracketBracedList: true +BreakAfterOpenBracketFunction: false +BreakAfterOpenBracketIf: false +BreakAfterOpenBracketLoop: false +BreakAfterOpenBracketSwitch: false +BreakAfterReturnType: Automatic +BreakArrays: false +BreakBeforeBinaryOperators: None +BreakBeforeCloseBracketBracedList: true +BreakBeforeCloseBracketFunction: true +BreakBeforeCloseBracketIf: true +BreakBeforeCloseBracketLoop: true +BreakBeforeCloseBracketSwitch: true +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Custom +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTemplateCloser: false +BreakBeforeTernaryOperators: true +BreakBinaryOperations: Never +BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: false +BreakTemplateDeclarations: Yes +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: Block +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +EnumTrailingComma: Leave +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: +IfMacros: +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 3 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExportBlock: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: true +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigitsInsert: 0 + BinaryMaxDigitsRemove: 0 + Decimal: 0 + DecimalMinDigitsInsert: 0 + DecimalMaxDigitsRemove: 0 + Hex: 0 + HexMinDigitsInsert: 0 + HexMaxDigitsRemove: 0 + BinaryMinDigits: 0 + DecimalMinDigits: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: true + AtStartOfBlock: false + AtStartOfFile: false +KeepFormFeed: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +NumericLiteralCase: + ExponentLetter: Leave + HexDigit: Leave + Prefix: Leave + Suffix: Leave +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +OneLineFormatOffRegex: '' +PackConstructorInitializers: NextLine +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakBeforeMemberAccess: 150 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: pb + BasedOnStyle: google +ReferenceAlignment: Pointer +ReflowComments: Always +RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: true +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: + Enabled: true + IgnoreCase: false + IgnoreExtension: false +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterOperatorKeyword: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeParensOptions: +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBraces: Never +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: c++23 +StatementAttributeLikeMacros: +StatementMacros: +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 4 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: +WrapNamespaceBodyWithEmptyLines: Always +... diff --git a/install/gojo-cpp-format b/install/gojo-cpp-format new file mode 100644 index 0000000..77c1c29 --- /dev/null +++ b/install/gojo-cpp-format @@ -0,0 +1,330 @@ +--- +Language: Cpp +AlignAfterOpenBracket: true +AccessModifierOffset: -1 +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: true + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + #AlignPPAndNotPP: true + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowBreakBeforeQtProperty: false +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AttributeMacros: +BinPackArguments: true +BinPackLongBracedList: true +BinPackParameters: BinPack +BitFieldColonSpacing: Both +BracedInitializerIndentWidth: -1 +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterOpenBracketBracedList: true +BreakAfterOpenBracketFunction: false +BreakAfterOpenBracketIf: false +BreakAfterOpenBracketLoop: false +BreakAfterOpenBracketSwitch: false +BreakAfterReturnType: Automatic +BreakArrays: false +BreakBeforeBinaryOperators: None +BreakBeforeCloseBracketBracedList: true +BreakBeforeCloseBracketFunction: true +BreakBeforeCloseBracketIf: true +BreakBeforeCloseBracketLoop: true +BreakBeforeCloseBracketSwitch: true +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Custom +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTemplateCloser: false +BreakBeforeTernaryOperators: true +BreakBinaryOperations: Never +BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: false +BreakTemplateDeclarations: Yes +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: Block +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +EnumTrailingComma: Leave +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: +IfMacros: +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 3 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExportBlock: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: true +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigitsInsert: 0 + BinaryMaxDigitsRemove: 0 + Decimal: 0 + DecimalMinDigitsInsert: 0 + DecimalMaxDigitsRemove: 0 + Hex: 0 + HexMinDigitsInsert: 0 + HexMaxDigitsRemove: 0 + BinaryMinDigits: 0 + DecimalMinDigits: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: true + AtStartOfBlock: false + AtStartOfFile: false +KeepFormFeed: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +NumericLiteralCase: + ExponentLetter: Leave + HexDigit: Leave + Prefix: Leave + Suffix: Leave +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +OneLineFormatOffRegex: '' +PackConstructorInitializers: NextLine +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakBeforeMemberAccess: 150 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: pb + BasedOnStyle: google +ReferenceAlignment: Pointer +ReflowComments: Always +RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: true +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: + Enabled: true + IgnoreCase: false + IgnoreExtension: false +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterOperatorKeyword: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeParensOptions: +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBraces: Never +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: c++23 +StatementAttributeLikeMacros: +StatementMacros: +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 4 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: +WrapNamespaceBodyWithEmptyLines: Always +... diff --git a/install.sh b/install/install.sh similarity index 96% rename from install.sh rename to install/install.sh index 1149e72..a6d1546 100755 --- a/install.sh +++ b/install/install.sh @@ -316,6 +316,8 @@ main() { mkdir -p "$HOME/.gojo" mkdir -p "$HOME/.gojo/profiles" mkdir -p "$HOME/.gojo/formats" + curl --proto '=https' --tlsv1.2 -sSf -L https://raw.githubusercontent.com/whuffman36/gojo/refs/heads/main/install/gojo-c-format > "$HOME/.gojo/formats/gojo-c" + curl --proto '=https' --tlsv1.2 -sSf -L https://raw.githubusercontent.com/whuffman36/gojo/refs/heads/main/install/gojo-cpp-format > "$HOME/.gojo/formats/gojo-c++" mkdir -p "$HOME/.gojo/bin" detect_os diff --git a/src/build_systems/cmake.cpp b/src/build_systems/cmake.cpp index 8d18e1c..915f106 100644 --- a/src/build_systems/cmake.cpp +++ b/src/build_systems/cmake.cpp @@ -47,7 +47,8 @@ void configure(const cfg::Config& cfg, bool verbose) { if (cfg.testing_enabled.has_value()) { if (cfg.testing_enabled.value()) { build_tests = " -DBUILD_TESTING=ON"; - } else { + } + else { build_tests = " -DBUILD_TESTING=OFF"; } } diff --git a/src/cfg/config.cpp b/src/cfg/config.cpp index 6eaee8f..f97277c 100644 --- a/src/cfg/config.cpp +++ b/src/cfg/config.cpp @@ -126,7 +126,8 @@ void validate_build_section(cfg::Config& cfg, const toml::table& table) { auto int_result { table[BUILD][BUILD_LANGUAGE_STD].value() }; if (!int_result.has_value()) { cfg.language_standard = std::nullopt; - } else { + } + else { const auto language_standard { cfg::language_std_from_int(int_result.value(), cfg.language) }; @@ -141,7 +142,8 @@ void validate_build_section(cfg::Config& cfg, const toml::table& table) { auto sv_result { table[BUILD][BUILD_COMPILER].value() }; if (!sv_result.has_value()) { cfg.compiler = std::nullopt; - } else { + } + else { const auto compiler { cfg::compiler_from_str(sv_result.value()) }; if (!compiler.has_value()) { throw std::runtime_error { std::format( @@ -156,7 +158,8 @@ void validate_build_section(cfg::Config& cfg, const toml::table& table) { auto array_result { table[BUILD][BUILD_COMPILER_FLAGS].as_array() }; if (array_result == nullptr || array_result->empty()) { cfg.compiler_flags = std::nullopt; - } else { + } + else { std::string compiler_flags {}; for (const auto& elem : *array_result) { auto flag { elem.value() }; @@ -172,14 +175,16 @@ void validate_build_section(cfg::Config& cfg, const toml::table& table) { const auto bool_result { table[BUILD][BUILD_GNU_EXTENSIONS].value() }; if (!bool_result.has_value()) { cfg.gnu_extensions_enabled = std::nullopt; - } else { + } + else { cfg.gnu_extensions_enabled = bool_result; } sv_result = table[BUILD][BUILD_BUILD_SYSTEM].value(); if (!sv_result.has_value()) { cfg.build_system = std::nullopt; - } else { + } + else { const auto build_system { cfg::build_system_from_str(sv_result.value()) }; @@ -194,7 +199,8 @@ void validate_build_section(cfg::Config& cfg, const toml::table& table) { sv_result = table[BUILD][BUILD_GENERATOR].value(); if (!sv_result.has_value()) { cfg.generator = std::nullopt; - } else { + } + else { const auto generator { cfg::generator_from_str(sv_result.value()) }; if (!generator.has_value()) { throw std::runtime_error { std::format( @@ -207,7 +213,8 @@ void validate_build_section(cfg::Config& cfg, const toml::table& table) { sv_result = table[BUILD][BUILD_BUILD_TYPE].value(); if (!sv_result.has_value()) { cfg.build_type = std::nullopt; - } else { + } + else { const auto build_type { cfg::build_type_from_str(sv_result.value()) }; if (!build_type.has_value()) { throw std::runtime_error { std::format( @@ -224,7 +231,8 @@ void validate_checks_section(cfg::Config& cfg, const toml::table& table) { }; if (!sv_result.has_value()) { cfg.clang_format_style = std::nullopt; - } else { + } + else { const auto format_style { cfg::fromat_style_from_str(sv_result.value()) }; @@ -240,21 +248,24 @@ void validate_checks_section(cfg::Config& cfg, const toml::table& table) { sv_result = table[CHECKS][CHECKS_LANGUAGE_SERVER].value(); if (!sv_result.has_value()) { cfg.language_server = std::nullopt; - } else { + } + else { cfg.language_server = sv_result.value(); } auto bool_result { table[CHECKS][CHECKS_CLANG_TIDY_ENABLED].value() }; if (!bool_result.has_value()) { cfg.clang_tidy_enabled = std::nullopt; - } else { + } + else { cfg.clang_tidy_enabled = bool_result; } auto array_result { table[CHECKS][CHECKS_CLANG_TIDY_ARGS].as_array() }; if (array_result == nullptr || array_result->empty()) { cfg.clang_tidy_args = std::nullopt; - } else { + } + else { std::string clang_tidy_args {}; for (const auto& elem : *array_result) { auto arg { elem.value() }; @@ -270,14 +281,16 @@ void validate_checks_section(cfg::Config& cfg, const toml::table& table) { bool_result = table[CHECKS][CHECKS_CPPCHECK_ENABLED].value(); if (!bool_result.has_value()) { cfg.cppcheck_enabled = std::nullopt; - } else { + } + else { cfg.cppcheck_enabled = bool_result; } array_result = table[CHECKS][CHECKS_CPPCHECK_CHECKS].as_array(); if (array_result == nullptr || array_result->empty()) { cfg.cppcheck_checks = std::nullopt; - } else { + } + else { std::string cppcheck_checks {}; for (const auto& elem : *array_result) { auto check { elem.value() }; @@ -293,7 +306,8 @@ void validate_checks_section(cfg::Config& cfg, const toml::table& table) { array_result = table[CHECKS][CHECKS_CPPCHECK_ARGS].as_array(); if (array_result == nullptr || array_result->empty()) { cfg.cppcheck_args = std::nullopt; - } else { + } + else { std::string cppcheck_args {}; for (const auto& elem : *array_result) { auto arg { elem.value() }; @@ -313,7 +327,8 @@ void validate_tests_section(cfg::Config& cfg, const toml::table& table) { }; if (!bool_result.has_value()) { cfg.testing_enabled = std::nullopt; - } else { + } + else { cfg.testing_enabled = bool_result; } @@ -322,7 +337,8 @@ void validate_tests_section(cfg::Config& cfg, const toml::table& table) { }; if (!sv_result.has_value()) { cfg.test_framework = std::nullopt; - } else { + } + else { const auto test_framework { cfg::test_framework_from_str(sv_result.value()) }; @@ -341,7 +357,8 @@ void validate_deps_section(cfg::Config& cfg, const toml::table& table) { }; if (!sv_result.has_value()) { cfg.package_manager = std::nullopt; - } else { + } + else { const auto package_manager { cfg::package_manager_from_str(sv_result.value()) }; @@ -359,7 +376,8 @@ void validate_deps_section(cfg::Config& cfg, const toml::table& table) { cfg.build_types.at(1) = std::nullopt; cfg.build_types.at(2) = std::nullopt; cfg.build_types.at(3) = std::nullopt; - } else { + } + else { if (array_result->size() > 4) { throw std::runtime_error { "deps.build_types can only contain up to four build_types" @@ -789,7 +807,8 @@ bool Config::is_multi_config() const { Generator tmp_generator {}; if (generator.has_value()) { tmp_generator = generator.value(); - } else { + } + else { tmp_generator = Generator::Default; } diff --git a/src/cfg/enums.cpp b/src/cfg/enums.cpp index 94066d1..be55843 100644 --- a/src/cfg/enums.cpp +++ b/src/cfg/enums.cpp @@ -45,24 +45,22 @@ std::optional language_std_from_int(std::uint8_t val, }; switch (language) { - case cfg::Language::C: - { - const auto result { c_map.find(val) }; - if (result == c_map.end()) { - return std::nullopt; - } - return result->second; - break; + case cfg::Language::C: { + const auto result { c_map.find(val) }; + if (result == c_map.end()) { + return std::nullopt; } - case cfg::Language::Cpp: - { - const auto result { cpp_map.find(val) }; - if (result == cpp_map.end()) { - return std::nullopt; - } - return result->second; - break; + return result->second; + break; + } + case cfg::Language::Cpp: { + const auto result { cpp_map.find(val) }; + if (result == cpp_map.end()) { + return std::nullopt; } + return result->second; + break; + } } } @@ -311,6 +309,7 @@ const std::string_view to_str(const PackageManager package_manager) { std::optional fromat_style_from_str(std::string_view str) { static const std::flat_map map { { "custom", FormatStyle::Custom }, + { "gojo", FormatStyle::Gojo }, { "google", FormatStyle::Google }, { "llvm", FormatStyle::Llvm }, { "chromium", FormatStyle::Chromium }, @@ -331,6 +330,7 @@ std::optional fromat_style_from_str(std::string_view str) { const std::string_view to_str(const FormatStyle format_style) { switch (format_style) { case FormatStyle::Custom: return "custom"; break; + case FormatStyle::Gojo: return "gojo"; break; case FormatStyle::Google: return "google"; break; case FormatStyle::Llvm: return "llvm"; break; case FormatStyle::Chromium: return "chromium"; break; diff --git a/src/cfg/enums.hpp b/src/cfg/enums.hpp index 93b62c6..5f8f1d1 100644 --- a/src/cfg/enums.hpp +++ b/src/cfg/enums.hpp @@ -159,6 +159,7 @@ const std::string_view to_str(const PackageManager package_manager); // Format Style enum class FormatStyle : std::uint8_t { Custom, + Gojo, Google, Llvm, Chromium, @@ -168,7 +169,7 @@ enum class FormatStyle : std::uint8_t { Gnu, }; -constexpr std::uint8_t FORMAT_STYLE_OPTIONS { 8 }; +constexpr std::uint8_t FORMAT_STYLE_OPTIONS { 9 }; std::optional fromat_style_from_str(std::string_view str); diff --git a/src/cmd/build.cpp b/src/cmd/build.cpp index 9b75f85..cd9426f 100644 --- a/src/cmd/build.cpp +++ b/src/cmd/build.cpp @@ -72,22 +72,29 @@ void build(std::span args) { for (const auto arg : args) { if (arg == "--release") { build_type = cfg::BuildType::Release; - } else if (arg == "--debug") { + } + else if (arg == "--debug") { build_type = cfg::BuildType::Debug; - } else if (arg == "--tests") { + } + else if (arg == "--tests") { testing_enabled = true; - } else if (arg == "--no-tests") { + } + else if (arg == "--no-tests") { testing_enabled = false; - } else if (arg == "--verbose" || arg == "-v") { + } + else if (arg == "--verbose" || arg == "-v") { verbose = true; - } else if (arg.starts_with("--target=")) { + } + else if (arg.starts_with("--target=")) { // Length of "--target=" constexpr std::size_t target_arg_len { 9 }; target = arg.substr(target_arg_len); - } else if (arg == "--help") { + } + else if (arg == "--help") { utils::gojo_print(utils::LogLevel::Info, HELP, INFO_COLORS); return; - } else { + } + else { throw std::runtime_error { std::format("gojo build: argument not recognized: {}", arg) }; @@ -118,7 +125,8 @@ void build(std::span args) { exists_in_dep_build_types = // NOLINTNEXTLINE(bugprone-unchecked-optional-access) cfg.build_types.at(idx).value() == build_type; - } else { + } + else { empty_idx = idx; } } diff --git a/src/cmd/check.cpp b/src/cmd/check.cpp index 6d77ce0..486cfef 100644 --- a/src/cmd/check.cpp +++ b/src/cmd/check.cpp @@ -49,10 +49,12 @@ void check(std::span args) { for (const auto arg : args) { if (arg == "--verbose" || arg == "-v") { verbose = true; - } else if (arg == "--help") { + } + else if (arg == "--help") { utils::gojo_print(utils::LogLevel::Info, HELP, INFO_COLORS); return; - } else { + } + else { throw std::runtime_error { std::format("gojo check: argument not recognized: {}", arg) }; diff --git a/src/cmd/clean.cpp b/src/cmd/clean.cpp index 4e1da94..6dc29f4 100644 --- a/src/cmd/clean.cpp +++ b/src/cmd/clean.cpp @@ -39,10 +39,12 @@ void clean(std::span args) { if (arg == "--deps") { deps = true; break; - } else if (arg == "--help") { + } + else if (arg == "--help") { utils::gojo_print(utils::LogLevel::Info, HELP, INFO_COLORS); return; - } else { + } + else { throw std::runtime_error { std::format("gojo clean: argument not recognized: {}", arg) }; diff --git a/src/cmd/dep.cpp b/src/cmd/dep.cpp index d4aece8..af4f5f0 100644 --- a/src/cmd/dep.cpp +++ b/src/cmd/dep.cpp @@ -114,8 +114,9 @@ void dep(std::span args) { throw std::runtime_error { std::format( "gojo dep install: argument not recognized: {}", args[1] ) }; - } else if (args.size() > 1 && - (args[1] == "--verbose" || args[1] == "-v")) { + } + else if (args.size() > 1 && + (args[1] == "--verbose" || args[1] == "-v")) { verbose = true; } switch (cfg.package_manager.value()) { @@ -129,87 +130,75 @@ void dep(std::span args) { } refresh(refresh_args); break; - case Subcommand::Add: - { - if (args.size() < 2) { - throw std::runtime_error { - "gojo dep add: missing argument" - }; - } - if (args.size() > 3) { - throw std::runtime_error { - "gojo dep add: too many arguments" - }; - } - std::string_view version { "latest" }; - if (args.size() == 3) { - version = args[2]; - } - switch (cfg.package_manager.value()) { - case cfg::PackageManager::Conan: - { - std::filesystem::path conanfile { - utils::get_root_dir() / "conanfile.py" - }; - if (!std::filesystem::exists(conanfile)) { - conanfile = - utils::get_root_dir() / "conanfile.txt"; - } - if (!std::filesystem::exists(conanfile)) { - throw std::runtime_error { std::format( - "file not found: {}", conanfile.string() - ) }; - } - conan::add(conanfile, args[1], version); - break; - } - case cfg::PackageManager::Vcpkg: break; - } - if (!verbose) { - refresh_args.clear(); - } - refresh(refresh_args); - break; - } - case Subcommand::Remove: - { - if (args.size() < 2) { - throw std::runtime_error { - "gojo dep remove: missing argument" - }; - } - if (args.size() > 2) { - throw std::runtime_error { - "gojo dep remove: too many arguments" - }; + case Subcommand::Add: { + if (args.size() < 2) { + throw std::runtime_error { "gojo dep add: missing argument" }; + } + if (args.size() > 3) { + throw std::runtime_error { "gojo dep add: too many arguments" }; + } + std::string_view version { "latest" }; + if (args.size() == 3) { + version = args[2]; + } + switch (cfg.package_manager.value()) { + case cfg::PackageManager::Conan: { + std::filesystem::path conanfile { utils::get_root_dir() / + "conanfile.py" }; + if (!std::filesystem::exists(conanfile)) { + conanfile = utils::get_root_dir() / "conanfile.txt"; + } + if (!std::filesystem::exists(conanfile)) { + throw std::runtime_error { std::format( + "file not found: {}", conanfile.string() + ) }; + } + conan::add(conanfile, args[1], version); + break; } + case cfg::PackageManager::Vcpkg: break; + } + if (!verbose) { + refresh_args.clear(); + } + refresh(refresh_args); + break; + } + case Subcommand::Remove: { + if (args.size() < 2) { + throw std::runtime_error { + "gojo dep remove: missing argument" + }; + } + if (args.size() > 2) { + throw std::runtime_error { + "gojo dep remove: too many arguments" + }; + } - switch (cfg.package_manager.value()) { - case cfg::PackageManager::Conan: - { - std::filesystem::path conanfile { - utils::get_root_dir() / "conanfile.py" - }; - if (!std::filesystem::exists(conanfile)) { - conanfile = - utils::get_root_dir() / "conanfile.txt"; - } - if (!std::filesystem::exists(conanfile)) { - throw std::runtime_error { std::format( - "file not found: {}", conanfile.string() - ) }; - } - conan::remove(conanfile, args[1]); - break; - } - case cfg::PackageManager::Vcpkg: break; - } - if (!verbose) { - refresh_args.clear(); + switch (cfg.package_manager.value()) { + case cfg::PackageManager::Conan: { + std::filesystem::path conanfile { utils::get_root_dir() / + "conanfile.py" }; + if (!std::filesystem::exists(conanfile)) { + conanfile = utils::get_root_dir() / "conanfile.txt"; + } + if (!std::filesystem::exists(conanfile)) { + throw std::runtime_error { std::format( + "file not found: {}", conanfile.string() + ) }; + } + conan::remove(conanfile, args[1]); + break; } - refresh(refresh_args); - break; + case cfg::PackageManager::Vcpkg: break; + } + if (!verbose) { + refresh_args.clear(); } + refresh(refresh_args); + break; + } case Subcommand::Uninstall: if (args.size() < 2) { throw std::runtime_error { @@ -223,11 +212,10 @@ void dep(std::span args) { } switch (cfg.package_manager.value()) { - case cfg::PackageManager::Conan: - { - conan::uninstall(args[1]); - break; - } + case cfg::PackageManager::Conan: { + conan::uninstall(args[1]); + break; + } case cfg::PackageManager::Vcpkg: break; } if (!verbose) { diff --git a/src/cmd/fmt.cpp b/src/cmd/fmt.cpp index a88ddd8..72bf85f 100644 --- a/src/cmd/fmt.cpp +++ b/src/cmd/fmt.cpp @@ -76,17 +76,20 @@ void fmt(std::span args) { if (arg == "--help") { utils::gojo_print(utils::LogLevel::Info, HELP, INFO_COLORS); return; - } else if (arg.starts_with("--use=")) { + } + else if (arg.starts_with("--use=")) { constexpr std::size_t arg_len { 6 }; copy_format_file(utils::get_root_dir() / ".clang-format", get_formats_dir() / arg.substr(arg_len)); break; - } else if (arg.starts_with("--save-as=")) { + } + else if (arg.starts_with("--save-as=")) { constexpr std::size_t arg_len { 10 }; copy_format_file(get_formats_dir() / arg.substr(arg_len), utils::get_root_dir() / ".clang-format"); return; - } else { + } + else { fmt_args = args_to_string(args); // Add space to the beginning for formatting. fmt_args.insert(fmt_args.begin(), ' '); @@ -98,9 +101,17 @@ void fmt(std::span args) { std::string style {}; if (cfg.clang_format_style.has_value()) { if (cfg.clang_format_style.value() == cfg::FormatStyle::Custom) { - style = " style=file"; - } else { - style = " style="; + style = " -style=file"; + } + else if (cfg.clang_format_style.value() == cfg::FormatStyle::Gojo) { + style = std::format( + " -style=file:{}-{}", + (utils::get_home_dir() / ".gojo" / "formats" / "gojo").string(), + utils::to_lower(cfg::to_str(cfg.language)) + ); + } + else { + style = " -style="; style.append(cfg::to_str(cfg.clang_format_style.value())); } } diff --git a/src/cmd/init.cpp b/src/cmd/init.cpp index be9c1eb..d96c6e0 100644 --- a/src/cmd/init.cpp +++ b/src/cmd/init.cpp @@ -349,7 +349,8 @@ std::string hello_world(); cfg.name, // {0} cfg.get_header_extension() // {1} ); - } else if (cfg.language == cfg::Language::C) { + } + else if (cfg.language == cfg::Language::C) { str = std::format( R"(#ifndef {0}_{0}_{1} #define {0}_{0}_{1} @@ -390,7 +391,8 @@ int main() {{ )", cfg.name, cfg.get_header_extension() ); - } else if (cfg.test_framework == cfg::TestFramework::GoogleTest) { + } + else if (cfg.test_framework == cfg::TestFramework::GoogleTest) { str = std::format( R"(#include @@ -421,7 +423,8 @@ int main(void) {{ )", cfg.name, cfg.get_header_extension() ); - } else if (cfg.test_framework == cfg::TestFramework::Unity) { + } + else if (cfg.test_framework == cfg::TestFramework::Unity) { str = std::format( R"(#include @@ -461,7 +464,8 @@ int main() { return 0; } )"; - } else if (cfg.test_framework == cfg::TestFramework::GoogleTest) { + } + else if (cfg.test_framework == cfg::TestFramework::GoogleTest) { str = R"(#include @@ -489,7 +493,8 @@ int main(void) { return 0; } )"; - } else if (cfg.test_framework == cfg::TestFramework::Unity) { + } + else if (cfg.test_framework == cfg::TestFramework::Unity) { str = R"(#include @@ -628,7 +633,8 @@ std::string conanfile(const cfg::Config& cfg) { if (cfg.is_testing_enabled()) { if (cfg.language == cfg::Language::Cpp) { reqs = "self.requires(\"gtest/1.17.0\")"; - } else if (cfg.language == cfg::Language::C) { + } + else if (cfg.language == cfg::Language::C) { reqs = "self.requires(\"unity/2.6.0\")"; } } @@ -688,22 +694,26 @@ class {0}Recipe(ConanFile): std::println("\nskipping..."); \ } \ success = true; \ - } else if (parsed_input > (num_options)) { \ + } \ + else if (parsed_input > (num_options)) { \ /* Invalid option. */ \ utils::gojo_print( \ utils::LogLevel::Error, \ "option must be one of the numbers in the list above" \ ); \ success = false; \ - } else { \ + } \ + else { \ cfg.field_name = static_cast(parsed_input - 1); \ success = true; \ } \ - } catch (const std::invalid_argument& e) { \ + } \ + catch (const std::invalid_argument& e) { \ utils::gojo_print(utils::LogLevel::Error, \ "option must be an integer"); \ success = false; \ - } catch (const std::out_of_range& e) { \ + } \ + catch (const std::out_of_range& e) { \ utils::gojo_print( \ utils::LogLevel::Error, \ "option must be one of the numbers in the list above" \ @@ -739,20 +749,24 @@ class {0}Recipe(ConanFile): std::println("\nskipping..."); \ } \ success = true; \ - } else if (parsed_input > 2) { \ + } \ + else if (parsed_input > 2) { \ /* Invalid option. */ \ utils::gojo_print(utils::LogLevel::Error, \ "option must be 0, 1, or 2"); \ success = false; \ - } else { \ + } \ + else { \ cfg.field_name = parsed_input == 1; \ success = true; \ } \ - } catch (const std::invalid_argument& e) { \ + } \ + catch (const std::invalid_argument& e) { \ utils::gojo_print(utils::LogLevel::Error, \ "option must be an integer"); \ success = false; \ - } catch (const std::out_of_range& e) { \ + } \ + catch (const std::out_of_range& e) { \ utils::gojo_print(utils::LogLevel::Error, \ "option must be 0, 1, or 2"); \ success = false; \ @@ -775,7 +789,8 @@ class {0}Recipe(ConanFile): std::println("\nskipping..."); \ } \ success = true; \ - } else { \ + } \ + else { \ cfg.field_name = input; \ if (verbose) { \ std::println("\nentered: {}", input); \ @@ -798,17 +813,20 @@ std::optional interactive_mode(std::istream& input_stream, std::getline(input_stream, input); if (input == "q") { return std::nullopt; - } else if (input.empty()) { + } + else if (input.empty()) { utils::gojo_print(utils::LogLevel::Error, "Project name is a required field"); success = false; break; - } else if (input.contains(' ')) { + } + else if (input.contains(' ')) { utils::gojo_print(utils::LogLevel::Error, "Project name must not contain spaces"); success = false; break; - } else { + } + else { cfg.name = input; if (verbose) { std::println("\nentered: {}", input); @@ -909,7 +927,8 @@ std::optional interactive_mode(std::istream& input_stream, "build type not recognized: {}", build_type); success = false; break; - } else { + } + else { // clang-format off // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-constant-array-index, cppcoreguidelines-pro-bounds-avoid-unchecked-container-access) cfg.build_types[num_build_types] = @@ -940,16 +959,21 @@ std::optional parse_arguments(std::span args, for (const auto arg : args) { if (arg == "--verbose" || arg == "-v") { cfg.verbose = true; - } else if (arg == "--interactive" || arg == "-i") { + } + else if (arg == "--interactive" || arg == "-i") { return interactive_mode(input, cfg.is_verbose_enabled()); - } else if (arg == "--lib") { + } + else if (arg == "--lib") { cfg.target = cfg::Target::Library; - } else if (arg.starts_with("--lang=")) { + } + else if (arg.starts_with("--lang=")) { if (arg.ends_with('c')) { cfg.language = cfg::Language::C; - } else if (arg.ends_with("c++")) { + } + else if (arg.ends_with("c++")) { cfg.language = cfg::Language::Cpp; - } else { + } + else { constexpr std::string_view fmt_str { "gojo init --lang: argument not recognized: {}\n" "\targument must be 'c' or 'c++'" @@ -961,9 +985,11 @@ std::optional parse_arguments(std::span args, std::format(fmt_str, arg.substr(lang_arg_len)) }; } - } else if (arg == "--tests") { + } + else if (arg == "--tests") { cfg.testing_enabled = true; - } else if (arg.starts_with("--profile=")) { + } + else if (arg.starts_with("--profile=")) { // length of "--profile=". constexpr size_t profile_arg_len { 10 }; const std::string_view profile_name { arg.substr(profile_arg_len) }; @@ -971,14 +997,17 @@ std::optional parse_arguments(std::span args, cfg = cfg::Config::from_file(utils::get_profiles_dir() / profile_name); cfg.name = tmp_name; - } else if (arg == "--help") { + } + else if (arg == "--help") { utils::gojo_print(utils::LogLevel::Info, HELP, INFO_COLORS); return std::nullopt; - } else if (arg.starts_with("--") || arg.starts_with('-')) { + } + else if (arg.starts_with("--") || arg.starts_with('-')) { throw std::runtime_error { std::format("gojo init: option not recognized: {}", arg) }; - } else { + } + else { cfg.name = arg; if (cfg.name.contains(' ')) { throw std::runtime_error { @@ -1084,11 +1113,10 @@ void init(std::span args, std::istream& input) { // init conan if (cfg.package_manager.has_value()) { switch (cfg.package_manager.value()) { - case cfg::PackageManager::Conan: - { - conan::install(cfg, cfg.is_verbose_enabled()); - break; - } + case cfg::PackageManager::Conan: { + conan::install(cfg, cfg.is_verbose_enabled()); + break; + } case cfg::PackageManager::Vcpkg: break; } } diff --git a/src/cmd/profile.cpp b/src/cmd/profile.cpp index 80fe248..d1e1789 100644 --- a/src/cmd/profile.cpp +++ b/src/cmd/profile.cpp @@ -82,66 +82,62 @@ void profile(std::span args) { } switch (subcommand.value()) { - case Subcommand::Create: - { - if (args.size() == 1) { - throw std::runtime_error { - "gojo profile create: missing name argument" - }; - } - if (args.size() > 2) { - throw std::runtime_error { - "gojo profile create: too many arguments" - }; - } - // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-avoid-unchecked-container-access) - const std::string_view name { args[1] }; - cfg::Config::this_project().to_file(utils::get_profiles_dir() / - name); - break; + case Subcommand::Create: { + if (args.size() == 1) { + throw std::runtime_error { + "gojo profile create: missing name argument" + }; } - case Subcommand::List: - { - if (args.size() > 1) { - throw std::runtime_error { - "gojo profile list: too many arguments" - }; - } - - for (const auto& profile : std::filesystem::directory_iterator { - utils::get_profiles_dir() }) { - utils::gojo_print(utils::LogLevel::Info, "{}", - profile.path().filename().string()); - } - break; + if (args.size() > 2) { + throw std::runtime_error { + "gojo profile create: too many arguments" + }; } - case Subcommand::Show: - { - if (args.size() == 1) { - throw std::runtime_error { - "gojo profile show: missing name argument" - }; - } - if (args.size() > 2) { - throw std::runtime_error { - "gojo profile show: too many arguments" - }; - } - // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-avoid-unchecked-container-access) - const std::string_view name { args[1] }; - std::string profile_contents {}; - if (name == "current") { - profile_contents = - utils::get_file_contents(utils::get_config_path()); - } else { - profile_contents = - utils::get_file_contents(utils::get_profiles_dir() / - name); - } + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-avoid-unchecked-container-access) + const std::string_view name { args[1] }; + cfg::Config::this_project().to_file(utils::get_profiles_dir() / + name); + break; + } + case Subcommand::List: { + if (args.size() > 1) { + throw std::runtime_error { + "gojo profile list: too many arguments" + }; + } + + for (const auto& profile : std::filesystem::directory_iterator { + utils::get_profiles_dir() }) { utils::gojo_print(utils::LogLevel::Info, "{}", - profile_contents); - break; + profile.path().filename().string()); + } + break; + } + case Subcommand::Show: { + if (args.size() == 1) { + throw std::runtime_error { + "gojo profile show: missing name argument" + }; + } + if (args.size() > 2) { + throw std::runtime_error { + "gojo profile show: too many arguments" + }; } + // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-avoid-unchecked-container-access) + const std::string_view name { args[1] }; + std::string profile_contents {}; + if (name == "current") { + profile_contents = + utils::get_file_contents(utils::get_config_path()); + } + else { + profile_contents = + utils::get_file_contents(utils::get_profiles_dir() / name); + } + utils::gojo_print(utils::LogLevel::Info, "{}", profile_contents); + break; + } case Subcommand::Delete: if (args.size() == 1) { throw std::runtime_error { @@ -158,7 +154,8 @@ void profile(std::span args) { if (name == "all") { std::filesystem::remove_all(utils::get_profiles_dir()); std::filesystem::create_directory(utils::get_profiles_dir()); - } else { + } + else { if (!std::filesystem::remove(utils::get_profiles_dir() / name)) { throw std::runtime_error { std::format( diff --git a/src/cmd/refresh.cpp b/src/cmd/refresh.cpp index 1235325..17e1b09 100644 --- a/src/cmd/refresh.cpp +++ b/src/cmd/refresh.cpp @@ -45,9 +45,11 @@ void refresh(std::span args) { if (arg == "--help") { utils::gojo_print(utils::LogLevel::Info, HELP, INFO_COLORS); return; - } else if (arg == "--verbose" || arg == "-v") { + } + else if (arg == "--verbose" || arg == "-v") { verbose = true; - } else { + } + else { throw std::runtime_error { std::format("gojo refresh: argument not recognized: {}", arg) }; diff --git a/src/cmd/run.cpp b/src/cmd/run.cpp index ac0f048..79806ad 100644 --- a/src/cmd/run.cpp +++ b/src/cmd/run.cpp @@ -58,7 +58,8 @@ void run(std::span args) { cmd = std::format("./build/src/{}/{} {}", cfg::to_str(cfg.get_build_type()), cfg.name, args_to_string(args)); - } else { + } + else { cmd = std::format("./build/{}/src/{} {}", cfg::to_str(cfg.get_build_type()), cfg.name, args_to_string(args)); diff --git a/src/cmd/test.cpp b/src/cmd/test.cpp index 839c92a..9b63570 100644 --- a/src/cmd/test.cpp +++ b/src/cmd/test.cpp @@ -40,12 +40,15 @@ void test(std::span args) { // Length of "--target=" constexpr std::size_t target_arg_len { 9 }; target = std::format(" -R \"{}\"", arg.substr(target_arg_len)); - } else if (arg == "--build") { + } + else if (arg == "--build") { build_first = true; - } else if (arg == "--help") { + } + else if (arg == "--help") { utils::gojo_print(utils::LogLevel::Info, HELP, INFO_COLORS); return; - } else { + } + else { throw std::runtime_error { std::format("gojo test: argument not recognized: {}", arg) }; diff --git a/src/gojo.cpp b/src/gojo.cpp index 2bf9648..c494407 100644 --- a/src/gojo.cpp +++ b/src/gojo.cpp @@ -122,7 +122,8 @@ int main(int argc, const char* argv[]) { utils::gojo_print(utils::LogLevel::Info, VERSION_STRING); break; } - } catch (const std::exception& e) { + } + catch (const std::exception& e) { utils::gojo_print(utils::LogLevel::Error, "{}", e.what()); utils::gojo_print(utils::LogLevel::Warning, "see gojo {} --help for more info", diff --git a/src/package_managers/conan.cpp b/src/package_managers/conan.cpp index 1aa6f55..0401949 100644 --- a/src/package_managers/conan.cpp +++ b/src/package_managers/conan.cpp @@ -109,19 +109,26 @@ Profile Profile::from_file(std::string_view profile_name) { if (label == "arch") { profile.arch = value; - } else if (label == "build_type") { + } + else if (label == "build_type") { profile.build_type = value; - } else if (label == "compiler") { + } + else if (label == "compiler") { profile.compiler = value; - } else if (label == "compiler.cppstd" || label == "compiler.cstd") { + } + else if (label == "compiler.cppstd" || label == "compiler.cstd") { profile.std = value; - } else if (label == "compiler.libcxx") { + } + else if (label == "compiler.libcxx") { profile.lib = value; - } else if (label == "compiler.version") { + } + else if (label == "compiler.version") { profile.compiler_version = value; - } else if (label == "os") { + } + else if (label == "os") { profile.os = value; - } else { + } + else { // Not a field that we need to care about, but we should still // copy it over to the profile for this project. profile.other_settings.append(std::format("{}={}\n", label, value)); diff --git a/src/utils.cpp b/src/utils.cpp index ca46f89..915e19d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -131,7 +131,8 @@ CommandResult execute_command( // If this code runs, it means execvp failed and this child process // should be killed. std::exit(EXIT_FAILURE); - } else { + } + else { // Parent process // Close write end of the pipe since this process only reads from the // child. @@ -149,7 +150,8 @@ CommandResult execute_command( read(pipefd.at(0), buffer.data(), BUFFER_SIZE)) > 0) { gojo_print(LogLevel::Info, "{}", buffer.data()); } - } else { + } + else { if (!logfile.has_value() && !capture_output) { gojo_print(LogLevel::Warning, "no logfile to write to"); } @@ -164,7 +166,8 @@ CommandResult execute_command( output.append(buffer.data(), static_cast(bytes_read)); } - } else { + } + else { while ((bytes_read = read(pipefd.at(0), buffer.data(), BUFFER_SIZE)) > 0) { gojo_log(logfile.value_or("/dev/null"), buffer.data(), @@ -187,11 +190,13 @@ CommandResult execute_command( if (WEXITSTATUS(status) == EXIT_SUCCESS) { // process exited in failure state return CommandResult { .output = output, .success = true }; - } else { + } + else { // Unknown exit code... return CommandResult { .output = output, .success = false }; } - } else { + } + else { // Process was killed or stopped return CommandResult { .output = output, .success = false }; } diff --git a/test/assets/formats/gojo-cpp b/test/assets/formats/gojo-cpp new file mode 100644 index 0000000..77c1c29 --- /dev/null +++ b/test/assets/formats/gojo-cpp @@ -0,0 +1,330 @@ +--- +Language: Cpp +AlignAfterOpenBracket: true +AccessModifierOffset: -1 +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: true + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionDeclarations: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + #AlignPPAndNotPP: true + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowBreakBeforeNoexceptSpecifier: Never +AllowBreakBeforeQtProperty: false +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AllowShortNamespacesOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AttributeMacros: +BinPackArguments: true +BinPackLongBracedList: true +BinPackParameters: BinPack +BitFieldColonSpacing: Both +BracedInitializerIndentWidth: -1 +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterOpenBracketBracedList: true +BreakAfterOpenBracketFunction: false +BreakAfterOpenBracketIf: false +BreakAfterOpenBracketLoop: false +BreakAfterOpenBracketSwitch: false +BreakAfterReturnType: Automatic +BreakArrays: false +BreakBeforeBinaryOperators: None +BreakBeforeCloseBracketBracedList: true +BreakBeforeCloseBracketFunction: true +BreakBeforeCloseBracketIf: true +BreakBeforeCloseBracketLoop: true +BreakBeforeCloseBracketSwitch: true +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Custom +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTemplateCloser: false +BreakBeforeTernaryOperators: true +BreakBinaryOperations: Never +BreakConstructorInitializers: BeforeColon +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: false +BreakTemplateDeclarations: Yes +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: Block +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +EnumTrailingComma: Leave +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: +IfMacros: +IncludeBlocks: Regroup +IncludeCategories: + - Regex: '^' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*\.h>' + Priority: 1 + SortPriority: 0 + CaseSensitive: false + - Regex: '^<.*' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 3 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '([-_](test|unittest))?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExportBlock: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: true +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigitsInsert: 0 + BinaryMaxDigitsRemove: 0 + Decimal: 0 + DecimalMinDigitsInsert: 0 + DecimalMaxDigitsRemove: 0 + Hex: 0 + HexMinDigitsInsert: 0 + HexMaxDigitsRemove: 0 + BinaryMinDigits: 0 + DecimalMinDigits: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: true + AtStartOfBlock: false + AtStartOfFile: false +KeepFormFeed: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +NumericLiteralCase: + ExponentLetter: Leave + HexDigit: Leave + Prefix: Leave + Suffix: Leave +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +OneLineFormatOffRegex: '' +PackConstructorInitializers: NextLine +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakBeforeMemberAccess: 150 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: pb + BasedOnStyle: google +ReferenceAlignment: Pointer +ReflowComments: Always +RemoveBracesLLVM: false +RemoveEmptyLinesInUnwrappedLines: true +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: + Enabled: true + IgnoreCase: false + IgnoreExtension: false +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterOperatorKeyword: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeParensOptions: +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBraces: Never +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: c++23 +StatementAttributeLikeMacros: +StatementMacros: +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 4 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: +WrapNamespaceBodyWithEmptyLines: Always +... diff --git a/test/fmt_test.cpp b/test/fmt_test.cpp index e378d6f..86835ed 100644 --- a/test/fmt_test.cpp +++ b/test/fmt_test.cpp @@ -6,6 +6,8 @@ #include #include +#include "src/cfg/config.hpp" +#include "src/cfg/enums.hpp" #include "src/cmd/commands.hpp" #include "src/utils.hpp" #include "test/utils.hpp" @@ -109,12 +111,40 @@ TEST(CommandsTest, FmtTestsLibC) { EXPECT_TRUE(cleanup_test_gojo_project(test_root_path())); } +TEST(CommandsTest, FmtTestGojoStyle) { + std::vector args { "format" }; + ASSERT_TRUE(init_test_gojo_project(test_root_path(), args)); + + cfg::Config cfg {}; + ASSERT_NO_THROW(cfg = cfg::Config::from_file(test_root_path() / "format" / + "gojo.toml")); + cfg.clang_format_style = cfg::FormatStyle::Gojo; + ASSERT_NO_THROW(cfg.to_file(test_root_path() / "format" / "gojo.toml")); + std::filesystem::create_directories(utils::get_home_dir() / ".gojo" / + "formats"); + + if (!std::filesystem::exists(utils::get_home_dir() / ".gojo" / "formats" / + "gojo-c++")) { + const auto str { utils::get_file_contents(get_assets_path() / + "formats" / "gojo-cpp") }; + std::ofstream gojo_format_file { utils::get_home_dir() / ".gojo" / + "formats" / "gojo-c++" }; + ASSERT_TRUE(gojo_format_file.is_open()); + gojo_format_file << str; + } + + args.clear(); + EXPECT_NO_THROW(cmd::fmt(args)); + + EXPECT_TRUE(cleanup_test_gojo_project(test_root_path())); +} + TEST(CommandsTest, FmtUse) { std::vector args { "format" }; ASSERT_TRUE(init_test_gojo_project(test_root_path(), args)); - ASSERT_TRUE(std::filesystem::create_directories(utils::get_home_dir() / - ".gojo" / "formats")); + std::filesystem::create_directories(utils::get_home_dir() / ".gojo" / + "formats"); std::ofstream src { utils::get_home_dir() / ".gojo" / "formats" / "test" }; ASSERT_TRUE(src.is_open()); diff --git a/test/init_test.cpp b/test/init_test.cpp index 529e084..38269a9 100644 --- a/test/init_test.cpp +++ b/test/init_test.cpp @@ -249,7 +249,7 @@ TEST(CommandsTest, InitInteractive) { // build type "2\n" // Option 2 (Release) // format-style - "5\n" // Option 5 (Mozilla) + "6\n" // Option 6 (Mozilla) // language server "\n" // Skip // clang-tidy enabled diff --git a/test/new_test.cpp b/test/new_test.cpp index cea8c9d..59ebefd 100644 --- a/test/new_test.cpp +++ b/test/new_test.cpp @@ -261,7 +261,7 @@ TEST(CommandsTest, NewInteractive) { // build type "2\n" // Option 2 (Release) // format-style - "5\n" // Option 5 (Mozilla) + "6\n" // Option 6 (Mozilla) // language server "\n" // Skip // clang-tidy enabled diff --git a/test/utils.hpp b/test/utils.hpp index 4405d76..f4b7a8f 100644 --- a/test/utils.hpp +++ b/test/utils.hpp @@ -17,8 +17,11 @@ constexpr std::string_view CONFIG_FULL { "config_full.toml" }; const std::filesystem::path get_assets_path() { // This code is run from /build/Debug/test // The assets path is /test/assets - static const std::filesystem::path ASSETS_PATH { "../../../test/assets" }; - return std::filesystem::absolute(ASSETS_PATH); + static const std::filesystem::path ASSETS_PATH { + std::filesystem::absolute("../../../test/assets") + }; + // return std::filesystem::absolute(ASSETS_PATH); + return ASSETS_PATH; } const std::filesystem::path get_config(const std::filesystem::path filepath) { @@ -37,7 +40,8 @@ bool init_test_gojo_project(const std::filesystem::path filepath, std::filesystem::current_path(filepath); try { cmd::init(args); - } catch (const std::exception& e) { + } + catch (const std::exception& e) { std::println("{}", e.what()); return false; } @@ -57,7 +61,8 @@ bool create_test_gojo_profile(const cfg::Config& cfg) { try { cfg.to_file(utils::get_profiles_dir() / "test"); - } catch (const std::exception& e) { + } + catch (const std::exception& e) { std::println("{}", e.what()); return false; } @@ -74,7 +79,8 @@ bool create_test_gojo_profile() { try { cfg::Config::from_file(get_config(CONFIG_MIN)) .to_file(utils::get_profiles_dir() / "test"); - } catch (const std::exception& e) { + } + catch (const std::exception& e) { std::println("{}", e.what()); return false; }