Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to limit version argument to --version #103

Merged
merged 1 commit into from
Jun 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}>
Expand Down
4 changes: 4 additions & 0 deletions include/argparse/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,11 @@ class ArgumentParser {
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);
}
Expand Down