1 class Cxxopts < Formula
2 desc "Lightweight C++ command-line option parser"
3 homepage "https://github.com/jarro2783/cxxopts"
4 url "https://github.com/jarro2783/cxxopts/archive/refs/tags/v3.2.1.tar.gz"
5 sha256 "841f49f2e045b9c6365997c2a8fbf76e6f215042dda4511a5bb04bc5ebc7f88a"
7 head "https://github.com/jarro2783/cxxopts.git", branch: "master"
10 sha256 cellar: :any_skip_relocation, all: "883a901ef150f303dfba9430fc0fd7f29a9f132406b35ebd9dcf481f23029957"
13 depends_on "cmake" => :build
17 -DCXXOPTS_BUILD_EXAMPLES=OFF
18 -DCXXOPTS_BUILD_TESTS=OFF
21 system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
22 system "cmake", "--build", "build"
23 system "cmake", "--install", "build"
27 (testpath/"test.cc").write <<~CPP
30 #include <cxxopts.hpp>
32 int main(int argc, char *argv[]) {
33 cxxopts::Options options(argv[0]);
37 ("e,echo", "String to be echoed", cxxopts::value(input))
38 ("h,help", "Print this help", cxxopts::value<bool>()->default_value("false"));
40 auto result = options.parse(argc, argv);
42 if (result.count("help")) {
43 std::cout << options.help() << std::endl;
47 std::cout << input << std::endl;
53 system ENV.cxx, "-std=c++11", "test.cc", "-I#{include}", "-o", "test"
54 assert_equal "echo string", shell_output("./test -e 'echo string'").strip
55 assert_equal "echo string", shell_output("./test --echo='echo string'").strip