mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-03 14:44:40 +00:00
Merge pull request #103 from kfsone/optional-v
Allow user to limit version argument to --version
This commit is contained in:
commit
64dd67c758
@ -1,12 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(argparse VERSION 1.0.0 LANGUAGES CXX)
|
||||
option(ARGPARSE_BUILD_TESTS OFF)
|
||||
option(ARGPARSE_LONG_VERSION_ARG_ONLY OFF)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
add_library(argparse INTERFACE)
|
||||
add_library(argparse::argparse ALIAS argparse)
|
||||
|
||||
if (ARGPARSE_LONG_VERSION_ARG_ONLY)
|
||||
target_compile_definitions(argparse INTERFACE ARGPARSE_LONG_VERSION_ARG_ONLY=true)
|
||||
endif ()
|
||||
|
||||
target_compile_features(argparse INTERFACE cxx_std_17)
|
||||
target_include_directories(argparse INTERFACE
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
|
@ -815,7 +815,11 @@ public:
|
||||
std::string aVersion = "1.0")
|
||||
: mProgramName(std::move(aProgramName)), mVersion(std::move(aVersion)) {
|
||||
add_argument("-h", "--help").help("shows help message and exits").nargs(0);
|
||||
#ifndef ARGPARSE_LONG_VERSION_ARG_ONLY
|
||||
add_argument("-v", "--version")
|
||||
#else
|
||||
add_argument("--version")
|
||||
#endif
|
||||
.help("prints version information and exits")
|
||||
.nargs(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user