mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-01-15 14:48:00 +00:00
Compare commits
2 Commits
93c90d1d93
...
6cc757f769
Author | SHA1 | Date | |
---|---|---|---|
|
6cc757f769 | ||
|
b856c0ba9c |
14
CPPLINT.cfg
Normal file
14
CPPLINT.cfg
Normal file
@ -0,0 +1,14 @@
|
||||
set noparent
|
||||
linelength=120 # As in .clang-format
|
||||
|
||||
# Non-used filters
|
||||
filter=-build/include_order # Requires unusual include order that encourages creating not self-contained headers
|
||||
filter=-readability/nolint # Conficts with clang-tidy
|
||||
filter=-runtime/references # Requires fundamental change of API, don't see need for this
|
||||
filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability
|
||||
filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format
|
||||
|
||||
# Filters to be included in future
|
||||
filter=-whitespace/indent,-whitespace/comments,-readability/braces,-build/include_what_you_use
|
||||
filter=-legal/copyright # Remove this line after Version 1.9
|
||||
|
@ -31,6 +31,14 @@ jobs:
|
||||
- script: git diff --exit-code --color
|
||||
displayName: Check tidy
|
||||
|
||||
- job: CppLint
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
container: sharaku/cpplint:latest
|
||||
steps:
|
||||
- bash: cpplint --counting=detailed --recursive examples include/CLI
|
||||
displayName: Checking against google style guide
|
||||
|
||||
# TODO: Fix macOS error and windows warning in c++17 mode
|
||||
- job: Native
|
||||
strategy:
|
||||
@ -97,4 +105,3 @@ jobs:
|
||||
- template: .ci/azure-cmake.yml
|
||||
- template: .ci/azure-build.yml
|
||||
- template: .ci/azure-test.yml
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
enum class Level : int { High, Medium, Low };
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
enum class Level : int { High, Medium, Low };
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
class MyFormatter : public CLI::Formatter {
|
||||
public:
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include "CLI/Timer.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <CLI/Timer.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CLI::AutoTimer("This is a timer");
|
||||
|
@ -1,5 +1,9 @@
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// This example is only built on GCC 7 on Travis due to mismatch in stdlib
|
||||
// for clang (CLI11 is forgiving about mismatches, json.hpp is not)
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
#include "CLI/CLI.hpp"
|
||||
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CLI::App test{R"raw(Modify the help print so that argument values are accessible.
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
// This example shows the usage of the retired and deprecated option helper methods
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
CLI::App cli_global{"Demo app"};
|
||||
|
@ -1,8 +1,6 @@
|
||||
// ===================================================================
|
||||
// subcommand_a.cpp
|
||||
// ===================================================================
|
||||
|
||||
#include "subcommand_a.hpp"
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
/// Set up a subcommand and capture a shared_ptr to a struct that holds all its options.
|
||||
/// The variables of the struct are bound to the CLI options.
|
||||
|
@ -1,9 +1,6 @@
|
||||
// ===================================================================
|
||||
// subcommand_a.hpp
|
||||
// ===================================================================
|
||||
#pragma once
|
||||
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <memory>
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <string>
|
||||
|
||||
/// Collection of all options of Subcommand A.
|
||||
|
@ -1,8 +1,5 @@
|
||||
// ===================================================================
|
||||
// main.cpp
|
||||
// ===================================================================
|
||||
|
||||
#include "subcommand_a.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CLI::App app{"..."};
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include "CLI/Timer.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <CLI/Timer.hpp>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
CLI::AutoTimer("This is a timer");
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "CLI/CLI.hpp"
|
||||
#include <CLI/CLI.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
|
@ -2657,9 +2657,7 @@ class App {
|
||||
auto res = op->get_flag_value(arg_name, value);
|
||||
op->add_result(res);
|
||||
parse_order_.push_back(op.get());
|
||||
}
|
||||
// --this=value
|
||||
else if(!value.empty()) {
|
||||
} else if(!value.empty()) { // --this=value
|
||||
op->add_result(value, result_count);
|
||||
parse_order_.push_back(op.get());
|
||||
collected += result_count;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <chrono> // NOLINT(build/c++11)
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -87,8 +87,9 @@ class Timer {
|
||||
/// This prints out a time string from a time
|
||||
std::string make_time_str(double time) const {
|
||||
auto print_it = [](double x, std::string unit) {
|
||||
std::array<char, 50> buffer;
|
||||
std::snprintf(buffer.data(), 50, "%.5g", x);
|
||||
const unsigned int buffer_length = 50;
|
||||
std::array<char, buffer_length> buffer;
|
||||
std::snprintf(buffer.data(), buffer_length, "%.5g", x);
|
||||
return buffer.data() + std::string(" ") + unit;
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
// file LICENSE or https://github.com/CLIUtils/CLI11 for details.
|
||||
|
||||
#include "StringTools.hpp"
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -595,9 +596,9 @@ template <typename T,
|
||||
bool lexical_cast(const std::string &input, T &output) {
|
||||
try {
|
||||
std::size_t n = 0;
|
||||
long long output_ll = std::stoll(input, &n, 0);
|
||||
std::int64_t output_ll = std::stoll(input, &n, 0);
|
||||
output = static_cast<T>(output_ll);
|
||||
return n == input.size() && static_cast<long long>(output) == output_ll;
|
||||
return n == input.size() && static_cast<std::int64_t>(output) == output_ll;
|
||||
} catch(const std::invalid_argument &) {
|
||||
return false;
|
||||
} catch(const std::out_of_range &) {
|
||||
@ -614,9 +615,9 @@ bool lexical_cast(const std::string &input, T &output) {
|
||||
|
||||
try {
|
||||
std::size_t n = 0;
|
||||
unsigned long long output_ll = std::stoull(input, &n, 0);
|
||||
std::uint64_t output_ll = std::stoull(input, &n, 0);
|
||||
output = static_cast<T>(output_ll);
|
||||
return n == input.size() && static_cast<unsigned long long>(output) == output_ll;
|
||||
return n == input.size() && static_cast<std::uint64_t>(output) == output_ll;
|
||||
} catch(const std::invalid_argument &) {
|
||||
return false;
|
||||
} catch(const std::out_of_range &) {
|
||||
|
@ -35,7 +35,7 @@
|
||||
#endif
|
||||
|
||||
#if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0
|
||||
#include <filesystem>
|
||||
#include <filesystem> // NOLINT(build/include)
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
Loading…
Reference in New Issue
Block a user