diff --git a/.clang-tidy b/.clang-tidy index f33ec61..10eb0f1 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,19 +1,28 @@ --- Checks: "-*, \ - modernize-deprecated-headers, \ - modernize-make-shared, \ - modernize-make-unique, \ - modernize-redundant-void-arg, \ - modernize-use-auto, \ - modernize-use-equals-default, \ - modernize-use-nullptr, \ - modernize-use-using, \ + modernize-*, \ + -modernize-avoid-c-arrays, \ + -modernize-pass-by-value, \ + -modernize-use-trailing-return-type, \ performance-faster-string-find, \ performance-for-range-copy, \ performance-inefficient-string-concatenation, \ performance-trivially-destructible, \ - readability-delete-null-pointer, \ - readability-duplicate-include, \ - readability-string-compare" + readability-*, \ + -readability-magic-numbers, \ + -readability-convert-member-functions-to-static, \ + -readability-isolate-declaration, \ + -readability-implicit-bool-conversion, \ + -readability-else-after-return, \ + -readability-braces-around-statements, \ + -readability-named-parameter, \ + -readability-identifier-length, \ + -readability-qualified-auto, \ + -readability-function-cognitive-complexity" + +CheckOptions: +- key: modernize-use-override.IgnoreDestructors + value: true + FormatStyle: file HeaderFilterRegex: 'include/.*.hh' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 45cb7ae..467ee46 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ ci: autoupdate_commit_msg: "chore: update pre-commit hooks" autofix_commit_msg: "style: pre-commit fixes" -exclude: ^include/(fmt|magic_enum|CLI11)/ +exclude: ^include/(fmt|magic_enum|CLI11|EcoMug)/ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 @@ -32,6 +32,14 @@ repos: - id: codespell args: ["-L", "hist"] +- repo: local + hooks: + - id: clang-tidy + name: clang-tidy + entry: bash -c 'command -V clang-tidy >&- 2>&-; if [[ $? == 0 && -d build ]]; then clang-tidy -fix -fix-errors -quiet -p=build "$@"; fi' + language: system + types_or: [c++] + - repo: https://github.com/pre-commit/mirrors-clang-format rev: v18.1.3 hooks: diff --git a/CMakeLists.txt b/CMakeLists.txt index 69ab077..48fd0aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,9 @@ set(CMAKE_INSTALL_MESSAGE LAZY) # Only allow installs relative to CMAKE_INSTALL_PREFIX set(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION ON) +# export compile commands, e.g. for use by clang-tidy. +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + # Set default build type include(BuildType) diff --git a/examples/02-hpge/HPGeTestStand.cc b/examples/02-hpge/HPGeTestStand.cc index 7c35c65..baaaabd 100644 --- a/examples/02-hpge/HPGeTestStand.cc +++ b/examples/02-hpge/HPGeTestStand.cc @@ -51,7 +51,7 @@ G4VPhysicalVolume* HPGeTestStand::DefineGeometry() { auto world_l = new G4LogicalVolume(world_s, LAr, "WorldLAr"); - auto world_p = new G4PVPlacement(nullptr, G4ThreeVector(), world_l, "World", 0, false, 0); + auto world_p = new G4PVPlacement(nullptr, G4ThreeVector(), world_l, "World", nullptr, false, 0); auto hpge_s = new G4Box("HPGe", 5 * u::cm, 5 * u::cm, 5 * u::cm); diff --git a/examples/02-hpge/HPGeTestStand.hh b/examples/02-hpge/HPGeTestStand.hh index 6bd3bd1..aa21780 100644 --- a/examples/02-hpge/HPGeTestStand.hh +++ b/examples/02-hpge/HPGeTestStand.hh @@ -7,7 +7,7 @@ class HPGeTestStand : public RMGHardware { public: - G4VPhysicalVolume* DefineGeometry(); + G4VPhysicalVolume* DefineGeometry() override; }; #endif diff --git a/examples/04-cosmogenics/HPGeTestStand.cc b/examples/04-cosmogenics/HPGeTestStand.cc index 7c35c65..baaaabd 100644 --- a/examples/04-cosmogenics/HPGeTestStand.cc +++ b/examples/04-cosmogenics/HPGeTestStand.cc @@ -51,7 +51,7 @@ G4VPhysicalVolume* HPGeTestStand::DefineGeometry() { auto world_l = new G4LogicalVolume(world_s, LAr, "WorldLAr"); - auto world_p = new G4PVPlacement(nullptr, G4ThreeVector(), world_l, "World", 0, false, 0); + auto world_p = new G4PVPlacement(nullptr, G4ThreeVector(), world_l, "World", nullptr, false, 0); auto hpge_s = new G4Box("HPGe", 5 * u::cm, 5 * u::cm, 5 * u::cm); diff --git a/examples/04-cosmogenics/HPGeTestStand.hh b/examples/04-cosmogenics/HPGeTestStand.hh index 6bd3bd1..aa21780 100644 --- a/examples/04-cosmogenics/HPGeTestStand.hh +++ b/examples/04-cosmogenics/HPGeTestStand.hh @@ -7,7 +7,7 @@ class HPGeTestStand : public RMGHardware { public: - G4VPhysicalVolume* DefineGeometry(); + G4VPhysicalVolume* DefineGeometry() override; }; #endif diff --git a/include/RMGEventAction.hh b/include/RMGEventAction.hh index be669e0..259a1b0 100644 --- a/include/RMGEventAction.hh +++ b/include/RMGEventAction.hh @@ -23,7 +23,6 @@ class RMGRunAction; class G4GenericMessenger; -class RMGVOutputManager; class RMGEventAction : public G4UserEventAction { public: diff --git a/include/RMGGermaniumDetector.hh b/include/RMGGermaniumDetector.hh index 33fe475..c6a4edd 100644 --- a/include/RMGGermaniumDetector.hh +++ b/include/RMGGermaniumDetector.hh @@ -20,6 +20,7 @@ #include #include "G4Allocator.hh" +#include "G4GenericMessenger.hh" #include "G4THitsCollection.hh" #include "G4ThreeVector.hh" #include "G4VHit.hh" @@ -56,7 +57,6 @@ using RMGGermaniumDetectorHitsCollection = G4THitsCollection det) { + inline const auto& GetDetectorMetadata(const std::pair& det) { return fDetectorMetadata.at(det); } inline const auto& GetActiveDetectorList() { return fActiveDetectors; } diff --git a/include/RMGHardwareMessenger.hh b/include/RMGHardwareMessenger.hh index e3ab068..8ee2873 100644 --- a/include/RMGHardwareMessenger.hh +++ b/include/RMGHardwareMessenger.hh @@ -26,7 +26,7 @@ class RMGHardwareMessenger : public G4UImessenger { RMGHardwareMessenger(RMGHardware* hw); ~RMGHardwareMessenger(); - void SetNewValue(G4UIcommand* command, G4String newValues); + void SetNewValue(G4UIcommand* command, G4String newValues) override; private: diff --git a/include/RMGLog.hh b/include/RMGLog.hh index 66d6e7b..ffb603a 100644 --- a/include/RMGLog.hh +++ b/include/RMGLog.hh @@ -114,10 +114,10 @@ class RMGLog { * Writes string to the screen log if the log level is equal or greater than the minimum * @param loglevel loglevel for the current message * @param message string to write to the screen log */ - template static void Out(RMGLog::LogLevel loglevel, const T& msg); + template static void Out(RMGLog::LogLevel loglevel, const T& message); template - static void Out(RMGLog::LogLevel loglevel, const T& msg_first, const Args&... msg_other); + static void Out(RMGLog::LogLevel loglevel, const T& msg_first, const Args&... args); template static void OutFormat(RMGLog::LogLevel loglevel, const std::string& fmt, const Args&... args); diff --git a/include/RMGManager.hh b/include/RMGManager.hh index 4d4901e..0ac84b1 100644 --- a/include/RMGManager.hh +++ b/include/RMGManager.hh @@ -52,12 +52,12 @@ class RMGManager { G4VisManager* GetG4VisManager(); RMGHardware* GetDetectorConstruction(); G4VUserPhysicsList* GetProcessesList(); - inline int GetPrintModulo() { return fPrintModulo; } + [[nodiscard]] inline int GetPrintModulo() const { return fPrintModulo; } inline bool IsExecSequential() { return fG4RunManager->GetRunManagerType() == G4RunManager::RMType::sequentialRM; } - inline bool IsPersistencyEnabled() { return fIsPersistencyEnabled; } + [[nodiscard]] inline bool IsPersistencyEnabled() const { return fIsPersistencyEnabled; } inline const std::string& GetOutputFileName() { return fOutputFile; } // setters @@ -83,7 +83,7 @@ class RMGManager { void SetRandEngineSeed(long seed); void SetRandEngineInternalSeed(int index); void SetRandSystemEntropySeed(); - inline bool GetRandIsControlled() { return fIsRandControlled; } + [[nodiscard]] inline bool GetRandIsControlled() const { return fIsRandControlled; } void SetLogLevel(std::string level); diff --git a/include/RMGMasterGenerator.hh b/include/RMGMasterGenerator.hh index 6f023da..81254fb 100644 --- a/include/RMGMasterGenerator.hh +++ b/include/RMGMasterGenerator.hh @@ -55,7 +55,7 @@ class RMGMasterGenerator : public G4VUserPrimaryGeneratorAction { inline RMGVGenerator* GetGenerator() { return fGeneratorObj.get(); } inline RMGVVertexGenerator* GetVertexGenerator() { return fVertexGeneratorObj.get(); } - inline Confinement GetConfinement() const { return fConfinement; } + [[nodiscard]] inline Confinement GetConfinement() const { return fConfinement; } void SetConfinement(Confinement code); void SetConfinementString(std::string code); @@ -65,10 +65,10 @@ class RMGMasterGenerator : public G4VUserPrimaryGeneratorAction { private: - Confinement fConfinement; + Confinement fConfinement{RMGMasterGenerator::Confinement::kUnConfined}; std::unique_ptr fVertexGeneratorObj; - Generator fGenerator; + Generator fGenerator{RMGMasterGenerator::Generator::kUndefined}; std::unique_ptr fGeneratorObj; std::unique_ptr fMessenger; diff --git a/include/RMGPhysics.hh b/include/RMGPhysics.hh index e46685b..2f2bb33 100644 --- a/include/RMGPhysics.hh +++ b/include/RMGPhysics.hh @@ -72,7 +72,7 @@ class RMGPhysics : public G4VModularPhysicsList { void SetPhysicsRealmString(std::string realm); void SetLowEnergyEMOptionString(std::string option); void SetUseGammaAngCorr(bool); - void SetGammaTwoJMAX(int two_j_max); + void SetGammaTwoJMAX(int max_two_j); void SetStoreICLevelData(bool); protected: diff --git a/include/RMGRun.hh b/include/RMGRun.hh index c6f9dc6..56cf6fe 100644 --- a/include/RMGRun.hh +++ b/include/RMGRun.hh @@ -26,7 +26,7 @@ class RMGRun : public G4Run { using TimePoint = std::chrono::time_point; - inline const TimePoint& GetStartTime() const { return fStartTime; } + [[nodiscard]] inline const TimePoint& GetStartTime() const { return fStartTime; } inline void SetStartTime(TimePoint t) { fStartTime = t; } private: diff --git a/include/RMGTrackingAction.hh b/include/RMGTrackingAction.hh index a6ce9c3..0b1d618 100644 --- a/include/RMGTrackingAction.hh +++ b/include/RMGTrackingAction.hh @@ -31,8 +31,8 @@ class RMGTrackingAction : public G4UserTrackingAction { RMGTrackingAction(RMGTrackingAction&&) = delete; RMGTrackingAction& operator=(RMGTrackingAction&&) = delete; - virtual void PreUserTrackingAction(const G4Track*) override; - virtual void PostUserTrackingAction(const G4Track*) override; + void PreUserTrackingAction(const G4Track*) override; + void PostUserTrackingAction(const G4Track*) override; inline G4TrackingManager* GetTrackingManager() { return G4UserTrackingAction::fpTrackingManager; }; diff --git a/include/RMGVVertexGenerator.hh b/include/RMGVVertexGenerator.hh index c0211bd..bbbc1c2 100644 --- a/include/RMGVVertexGenerator.hh +++ b/include/RMGVVertexGenerator.hh @@ -52,10 +52,10 @@ class RMGVVertexGenerator { return false; } inline void SetMaxAttempts(int val) { fMaxAttempts = val; } - inline int GetMaxAttempts() { return fMaxAttempts; } + [[nodiscard]] inline int GetMaxAttempts() const { return fMaxAttempts; } #if RMG_HAS_BXDECAY0 - inline void ShootVertex(G4ThreeVector& v) { GenerateVertex(v); } + inline void ShootVertex(G4ThreeVector& v) override { GenerateVertex(v); } #endif protected: diff --git a/include/RMGVertexConfinement.hh b/include/RMGVertexConfinement.hh index f232a87..6168be3 100644 --- a/include/RMGVertexConfinement.hh +++ b/include/RMGVertexConfinement.hh @@ -34,7 +34,7 @@ class RMGVertexConfinement : public RMGVVertexGenerator { public: struct GenericGeometricalSolidData { - std::string g4_name = ""; + std::string g4_name; G4ThreeVector volume_center = G4ThreeVector(0, 0, 0); double sphere_inner_radius = 0; double sphere_outer_radius = -1; @@ -98,19 +98,19 @@ class RMGVertexConfinement : public RMGVVertexGenerator { SampleableObjectCollection() = default; inline ~SampleableObjectCollection() { data.clear(); } - const SampleableObject& SurfaceWeightedRand() const; - const SampleableObject& VolumeWeightedRand() const; - bool IsInside(const G4ThreeVector& point) const; + [[nodiscard]] const SampleableObject& SurfaceWeightedRand() const; + [[nodiscard]] const SampleableObject& VolumeWeightedRand() const; + [[nodiscard]] bool IsInside(const G4ThreeVector& vertex) const; // emulate std::vector - size_t size() const { return data.size(); } + [[nodiscard]] size_t size() const { return data.size(); } SampleableObject& at(size_t i) { return data.at(i); } void emplace_back(G4VPhysicalVolume* v, const G4RotationMatrix& r, const G4ThreeVector& t, G4VSolid* s); inline void push_back(const SampleableObject& obj) { this->emplace_back(obj.physical_volume, obj.rotation, obj.translation, obj.sampling_solid); } - inline bool empty() const { return data.empty(); } + [[nodiscard]] inline bool empty() const { return data.empty(); } inline SampleableObject& back() { return data.back(); } inline void clear() { data.clear(); } inline void insert(SampleableObjectCollection& other) { diff --git a/include/RMGVertexFromFile.hh b/include/RMGVertexFromFile.hh index 93c50a9..a6a653c 100644 --- a/include/RMGVertexFromFile.hh +++ b/include/RMGVertexFromFile.hh @@ -24,7 +24,6 @@ #include "G4GenericMessenger.hh" #include "G4ThreeVector.hh" -class G4Event; class G4VAnalysisReader; class RMGVertexFromFile : public RMGVVertexGenerator { diff --git a/src/RMGGeneratorUtil.cc b/src/RMGGeneratorUtil.cc index f465c32..1eed945 100644 --- a/src/RMGGeneratorUtil.cc +++ b/src/RMGGeneratorUtil.cc @@ -28,10 +28,8 @@ #endif bool RMGGeneratorUtil::IsSampleable(std::string g4_solid_type) { - if (g4_solid_type == "G4Box" or g4_solid_type == "G4Orb" or g4_solid_type == "G4Sphere" or - g4_solid_type == "G4Tubs") - return true; - else return false; + return g4_solid_type == "G4Box" or g4_solid_type == "G4Orb" or g4_solid_type == "G4Sphere" or + g4_solid_type == "G4Tubs"; } G4ThreeVector RMGGeneratorUtil::rand(const G4VSolid* vol, bool on_surface) { @@ -45,7 +43,7 @@ G4ThreeVector RMGGeneratorUtil::rand(const G4VSolid* vol, bool on_surface) { return RMGGeneratorUtil::rand(dynamic_cast(vol), on_surface); else { RMGLog::OutDev(RMGLog::fatal, "'", entity, "' is not supported (implement me)"); - return G4ThreeVector(); + return {}; } } @@ -78,10 +76,9 @@ G4ThreeVector RMGGeneratorUtil::rand(const G4Box* box, bool on_surface) { y = dy * (2 * _g4rand() - 1); z = dz * (2 * _g4rand() - 1); } - return G4ThreeVector(x, y, z); + return {x, y, z}; } else { - return G4ThreeVector(dx * (2 * _g4rand() - 1), dy * (2 * _g4rand() - 1), - dz * (2 * _g4rand() - 1)); + return {dx * (2 * _g4rand() - 1), dy * (2 * _g4rand() - 1), dz * (2 * _g4rand() - 1)}; } } diff --git a/src/RMGGermaniumDetector.cc b/src/RMGGermaniumDetector.cc index bef554c..42ff8b7 100644 --- a/src/RMGGermaniumDetector.cc +++ b/src/RMGGermaniumDetector.cc @@ -38,7 +38,7 @@ G4ThreadLocal G4Allocator* RMGGermaniumDetectorHitAlloc // NOTE: does this make sense? G4bool RMGGermaniumDetectorHit::operator==(const RMGGermaniumDetectorHit& right) const { - return (this == &right) ? true : false; + return this == &right; } void RMGGermaniumDetectorHit::Print() { @@ -131,7 +131,7 @@ bool RMGGermaniumDetector::ProcessHits(G4Step* step, G4TouchableHistory* /*histo return true; } -void RMGGermaniumDetector::EndOfEvent(G4HCofThisEvent* /*hit_coll*/) { return; } +void RMGGermaniumDetector::EndOfEvent(G4HCofThisEvent* /*hit_coll*/) {} void RMGGermaniumDetector::DefineCommands() { diff --git a/src/RMGHardware.cc b/src/RMGHardware.cc index 1577bde..b86418a 100644 --- a/src/RMGHardware.cc +++ b/src/RMGHardware.cc @@ -135,7 +135,7 @@ void RMGHardware::ConstructSDandField() { fActiveDetectorsInitialized = true; } - std::string vec_repr = ""; + std::string vec_repr; for (const auto& d : fActiveDetectors) vec_repr += std::string(magic_enum::enum_name(d)) + ", "; if (vec_repr.size() > 2) vec_repr.erase(vec_repr.size() - 2); RMGLog::OutFormat(RMGLog::debug, "List of activated detectors: [{}]", vec_repr); diff --git a/src/RMGLog.cc b/src/RMGLog.cc index 069528c..5544048 100644 --- a/src/RMGLog.cc +++ b/src/RMGLog.cc @@ -55,12 +55,14 @@ RMGLog::RMGLog() { void RMGLog::StartupInfo() { - std::string message = ""; - message += " _ __ ___ _ __ ___ __ _ __ _ ___ \n"; - message += " | '__/ _ \\ '_ ` _ \\ / _` |/ _` |/ _ \\\n"; - message += " | | | __/ | | | | | (_| | (_| | __/\n"; - message += " |_| \\___|_| |_| |_|\\__,_|\\__, |\\___| v" + RMGLog::fVersion + "\n"; - message += " |___/ \n"; + std::string message; + // clang-format off + message += R"( _ __ ___ _ __ ___ __ _ __ _ ___ )" "\n"; + message += R"( | '__/ _ \ '_ ` _ \ / _` |/ _` |/ _ \)" "\n"; + message += R"( | | | __/ | | | | | (_| | (_| | __/)" "\n"; + message += R"( |_| \___|_| |_| |_|\__,_|\__, |\___| v)" + RMGLog::fVersion + "\n"; + message += R"( |___/ )" "\n"; + // clang-format on // write message to screen if (RMGLog::fMinimumLogLevel <= RMGLog::summary) G4cout << message << G4endl; diff --git a/src/RMGManager.cc b/src/RMGManager.cc index 4b1bbac..3dacaca 100644 --- a/src/RMGManager.cc +++ b/src/RMGManager.cc @@ -85,7 +85,7 @@ void RMGManager::Initialize() { if (!fG4VisManager) this->SetUpDefaultG4VisManager(); fG4VisManager->Initialize(); - std::string _str = ""; + std::string _str; for (const auto& i : fG4VisManager->GetAvailableGraphicsSystems()) { _str += i->GetNickname() + " "; } diff --git a/src/RMGMasterGenerator.cc b/src/RMGMasterGenerator.cc index 8cb090d..fc0340e 100644 --- a/src/RMGMasterGenerator.cc +++ b/src/RMGMasterGenerator.cc @@ -34,9 +34,7 @@ #include "RMGTools.hh" -RMGMasterGenerator::RMGMasterGenerator() - : fConfinement(RMGMasterGenerator::Confinement::kUnConfined), fVertexGeneratorObj(nullptr), - fGenerator(RMGMasterGenerator::Generator::kUndefined), fGeneratorObj(nullptr) { +RMGMasterGenerator::RMGMasterGenerator() : fVertexGeneratorObj(nullptr), fGeneratorObj(nullptr) { this->DefineCommands(); } diff --git a/src/RMGOpticalDetector.cc b/src/RMGOpticalDetector.cc index 8b91f7c..74eee3a 100644 --- a/src/RMGOpticalDetector.cc +++ b/src/RMGOpticalDetector.cc @@ -34,7 +34,7 @@ G4ThreadLocal G4Allocator* RMGOpticalDetectorHitAllocator // NOTE: does this make sense? G4bool RMGOpticalDetectorHit::operator==(const RMGOpticalDetectorHit& right) const { - return (this == &right) ? true : false; + return this == &right; } void RMGOpticalDetectorHit::Print() { @@ -115,7 +115,7 @@ bool RMGOpticalDetector::ProcessHits(G4Step* step, G4TouchableHistory* /*history return true; } -void RMGOpticalDetector::EndOfEvent(G4HCofThisEvent* /*hit_coll*/) { return; } +void RMGOpticalDetector::EndOfEvent(G4HCofThisEvent* /*hit_coll*/) {} void RMGOpticalDetector::DefineCommands() { diff --git a/src/RMGPhysics.cc b/src/RMGPhysics.cc index f3742ba..b7d74ee 100644 --- a/src/RMGPhysics.cc +++ b/src/RMGPhysics.cc @@ -53,7 +53,7 @@ namespace u = CLHEP; -RMGPhysics::RMGPhysics() : G4VModularPhysicsList() { +RMGPhysics::RMGPhysics() { G4VUserPhysicsList::defaultCutValue = 0.1 * u::mm; this->SetPhysicsRealm(RMGPhysics::kDoubleBetaDecay); @@ -91,21 +91,12 @@ void RMGPhysics::ConstructParticle() { RMGLog::Out(RMGLog::detail, "Constructing particles"); - G4BosonConstructor boson_const; - G4LeptonConstructor lepton_const; - G4MesonConstructor meson_const; - G4BaryonConstructor baryon_const; - G4IonConstructor ion_const; - G4ShortLivedConstructor short_lived_const; - - boson_const.ConstructParticle(); - lepton_const.ConstructParticle(); - meson_const.ConstructParticle(); - baryon_const.ConstructParticle(); - ion_const.ConstructParticle(); - short_lived_const.ConstructParticle(); - - return; + G4BosonConstructor::ConstructParticle(); + G4LeptonConstructor::ConstructParticle(); + G4MesonConstructor::ConstructParticle(); + G4BaryonConstructor::ConstructParticle(); + G4IonConstructor::ConstructParticle(); + G4ShortLivedConstructor::ConstructParticle(); } //////////////////////////////////////////////////////////////////////////////////////////// @@ -160,9 +151,9 @@ void RMGPhysics::ConstructProcess() { // e+/e- nuclear interactions RMGLog::Out(RMGLog::detail, "Adding extra electromagnetic physics"); auto em_extra_physics = new G4EmExtraPhysics(G4VModularPhysicsList::verboseLevel); - em_extra_physics->Synch("on"); - em_extra_physics->GammaNuclear("on"); - em_extra_physics->MuonNuclear("on"); + em_extra_physics->Synch(true); + em_extra_physics->GammaNuclear(true); + em_extra_physics->MuonNuclear(true); em_extra_physics->ConstructProcess(); if (fConstructOptical) this->ConstructOptical(); diff --git a/src/remage.cc b/src/remage.cc index bb1d3ea..5a63229 100644 --- a/src/remage.cc +++ b/src/remage.cc @@ -23,20 +23,18 @@ #include "magic_enum/magic_enum.hpp" -namespace CLI { - namespace detail { - bool lexical_cast(std::string input, RMGLog::LogLevel& output) { - try { - output = static_cast(std::stoll(input)); - return true; - } catch (...) { - auto r = magic_enum::enum_cast(input); - if (r.has_value()) output = r.value(); - return r.has_value(); - } +namespace CLI::detail { + bool lexical_cast(std::string input, RMGLog::LogLevel& output) { + try { + output = static_cast(std::stoll(input)); + return true; + } catch (...) { + auto r = magic_enum::enum_cast(input); + if (r.has_value()) output = r.value(); + return r.has_value(); } - } // namespace detail -} // namespace CLI + } +} // namespace CLI::detail #include "CLI11/CLI11.hpp" @@ -57,9 +55,7 @@ int main(int argc, char** argv) { app.add_flag("-q", quiet, "Print only warnings and errors"); app.add_flag("-v", verbosity, "Increase verbosity"); - app.add_option("-l,--log-level", loglevel, log_level_desc.c_str()) - ->type_name("LEVEL") - ->default_val("summary"); + app.add_option("-l,--log-level", loglevel, log_level_desc)->type_name("LEVEL")->default_val("summary"); app.add_flag("-i,--interactive", interactive, "Run in interactive mode"); app.add_option("-t,--threads", nthreads, "Number of threads");