diff --git a/src/main.cxx b/src/main.cxx index fdfd7c1..f13c5ed 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -35,7 +35,10 @@ int main(int argc, char* argv[], char* envp[]) log(DISPLAY, "Available arguments list:"); for (auto& arg : args) { - log(DISPLAY, "\t[%s] %s", arg.name.data(), arg.note.data()); + if (arg.note_help.size() == 0) + continue; + + log(DISPLAY, "%s", arg.note_help.data()); } log(DISPLAY, "\nSource code page: https://github.com/GloryOfNight/clang-format-all.git"); @@ -200,7 +203,10 @@ void parseArgs(int argc, char* argv[]) } else { - log(ERROR, "Unknown argument: %s", arg); + if (arg.ends_with("clang-format-all") || arg.ends_with("clang-format-all.exe")) + continue; + + log(ERROR, "Unknown argument: %s", arg.data()); } } } @@ -216,10 +222,10 @@ void parseEnvp(char* envp[]) const auto found_env = std::find_if(std::begin(env_vars), std::end(env_vars), [&env_name](const val_ref& val) { return val.name == env_name; }); - // if env variable found - // separate variable from it's contents - // check if env_var we found are supported type - // save contents to env + // if found_env variable found + // separate env variable from it's contents + // check if found_env are supported type + // save contents to found_env if (found_env != std::end(env_vars)) { const std::string_view env_value = env.substr(env.find_first_of('=') + 1); diff --git a/src/statics.hxx b/src/statics.hxx index 6abb0df..47d342b 100644 --- a/src/statics.hxx +++ b/src/statics.hxx @@ -10,16 +10,16 @@ struct val_ref // helper struct to improve workflow for command line arguments { template - constexpr val_ref(const std::string_view& inName, const std::string_view& inNote, T& inValue) + constexpr val_ref(const std::string_view& inName, T& inValue, const std::string_view& inNoteHelp) : name{inName} - , note{inNote} + , note_help{inNoteHelp} , value{&inValue} , type{typeid(T)} { } std::string_view name; - std::string_view note; + std::string_view note_help; void* value; const std::type_info& type; @@ -40,13 +40,13 @@ static std::vector ignorePaths{}; // paths to ignore with // clang-format off static constexpr auto args = std::array { - val_ref{"--help", "print help", printHelp}, - val_ref{"--no-logs", "disable logs (might improve performance slightly)", logPrintNone}, - val_ref{"--verbose", "enable verbose logs", logPrintVerbose}, - val_ref{"-S", "source directory to format", sourceDir}, - val_ref{"-E", "clang-format executable path", formatExecPath}, - val_ref{"-I", "space separated list of paths to ignore relative to [-S]", ignorePaths}, - val_ref{"-C", "additional command-line arguments for clang-format executable", formatCommands} + val_ref{"--help", printHelp, "--help = print help" }, + val_ref{"--no-logs", logPrintNone, "--no-logs = disable logs (might improve performance slightly)" }, + val_ref{"--verbose", logPrintVerbose, "--verbose = enable verbose logs" }, + val_ref{"-S", sourceDir, "-S = directory to format" }, + val_ref{"-E", formatExecPath, "-E = clang-format executable path" }, + val_ref{"-I", ignorePaths, "-I = list of paths to ignore relative to -S" }, + val_ref{"-C", formatCommands, "-C = additional command-line arguments for clang-format executable" } }; // clang-format on @@ -54,7 +54,7 @@ static std::string_view llvm; // clang-format off static constexpr auto env_vars = std::array { - val_ref{"LLVM","", llvm} + val_ref{"LLVM", llvm, ""} }; // clang-format on