mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-01 13:13:53 +00:00
Adding nicer header with LICENSE to single file version (#107)
* Adding nicer header with LICENSE to single file version * Adding badges * Clean up sh files * Adding explicit in a few places * More fixes from codacy
This commit is contained in:
parent
3520d6cfd7
commit
b23275358a
@ -3,7 +3,7 @@
|
||||
# Title : generateDocumentationAndDeploy.sh
|
||||
# Date created : 2016/02/22
|
||||
# Notes :
|
||||
__AUTHOR__="Jeroen de Bruijn"
|
||||
# Author : Jeroen de Bruijn
|
||||
# Preconditions:
|
||||
# - Packages doxygen doxygen-doc doxygen-latex doxygen-gui graphviz
|
||||
# must be installed.
|
||||
@ -29,7 +29,7 @@ __AUTHOR__="Jeroen de Bruijn"
|
||||
# the gh-pages branch of a repository specified by GH_REPO_REF.
|
||||
# Before this script is used there should already be a gh-pages branch in the
|
||||
# repository.
|
||||
#
|
||||
#
|
||||
################################################################################
|
||||
|
||||
################################################################################
|
||||
@ -38,8 +38,8 @@ echo 'Setting up the script...'
|
||||
# Exit with nonzero exit code if anything fails
|
||||
set -e
|
||||
|
||||
GH_REPO_ORG=`echo $TRAVIS_REPO_SLUG | cut -d "/" -f 1`
|
||||
GH_REPO_NAME=`echo $TRAVIS_REPO_SLUG | cut -d "/" -f 2`
|
||||
GH_REPO_ORG=$(echo $TRAVIS_REPO_SLUG | cut -d "/" -f 1)
|
||||
GH_REPO_NAME=$(echo $TRAVIS_REPO_SLUG | cut -d "/" -f 2)
|
||||
GH_REPO_REF="github.com/$GH_REPO_ORG/$GH_REPO_NAME.git"
|
||||
|
||||
# Create a clean working directory for this script.
|
||||
|
@ -1,3 +1,6 @@
|
||||
#!/bin/env sh
|
||||
# (Source me)
|
||||
|
||||
set -evx
|
||||
|
||||
DOXYGEN_URL="ftp://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.13.src.tar.gz"
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/bin/env sh
|
||||
# (Source me)
|
||||
set -evx
|
||||
|
||||
LCOV_URL="http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.13.orig.tar.gz"
|
||||
|
@ -1,4 +1,8 @@
|
||||
## Version 1.5.1: Access
|
||||
### Version 1.5.2: LICENSE in single header mode
|
||||
|
||||
This is a quick patch release that makes LICENSE part of the single header file, making it easier to include. Minor cleanup from codacy. No significant code changes from 1.5.1.
|
||||
|
||||
### Version 1.5.1: Access
|
||||
|
||||
This patch release adds better access to the App progromatically, to assist with writing custom converters to other formats. It also improves the help output, and uses a new feature in CLI11 1.5 to fix an old "quirk" in the way unlimited options and positionals interact.
|
||||
|
||||
|
30
LICENSE
30
LICENSE
@ -1,11 +1,25 @@
|
||||
CLI11 1.0 Copyright (c) 2017 University of Cincinnati, developed by Henry Schreiner under NSF AWARD 1414736.
|
||||
All rights reserved.
|
||||
CLI11 1.5 Copyright (c) 2017-2018 University of Cincinnati, developed by Henry
|
||||
Schreiner under NSF AWARD 1414736. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms of CLI11, with or without modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
Redistribution and use in source and binary forms of CLI11, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
@ -1,16 +1,17 @@
|
||||
[![Build Status Linux and macOS][travis-badge]][Travis]
|
||||
[![Build Status Windows][appveyor-badge]][AppVeyor]
|
||||
[![Code Coverage][codecov-badge]][CodeCov]
|
||||
[![Codacy Badge][codacy-badge]][codacy-link]
|
||||
[![Join the chat at https://gitter.im/CLI11gitter/Lobby][gitter-badge]][gitter]
|
||||
[![License: BSD][license-badge]](./LICENSE)
|
||||
[![Latest release][releases-badge]][Github Releases]
|
||||
[![DOI][DOI-badge]][DOI-link]
|
||||
[![Conan.io][conan-badge]][conan-link]
|
||||
[![Try CLI11 1.5 online][wandbox-badge]][wandbox-link]
|
||||
|
||||
[Documentation][GitBook] •
|
||||
[API Reference][api-docs] •
|
||||
[What's new](./CHANGELOG.md) •
|
||||
[Try CLI11 1.5 online][wandbox-link]
|
||||
[What's new](./CHANGELOG.md)
|
||||
|
||||
# CLI11: Command line parser for C++11
|
||||
|
||||
@ -444,7 +445,7 @@ CLI11 was developed at the [University of Cincinnati] to support of the [GooFit]
|
||||
[Clara]: https://github.com/philsquared/Clara
|
||||
[Version 1.0 post]: https://iscinumpy.gitlab.io/post/announcing-cli11-10/
|
||||
[Version 1.3 post]: https://iscinumpy.gitlab.io/post/announcing-cli11-13/
|
||||
[wandbox-online]: https://img.shields.io/badge/try%20it-online-orange.svg
|
||||
[wandbox-badge]: https://img.shields.io/badge/try-online-blue.svg
|
||||
[wandbox-link]: https://wandbox.org/permlink/3a2C5qg6vUjSSpr7
|
||||
[releases-badge]: https://img.shields.io/github/release/CLIUtils/CLI11.svg
|
||||
[cli11-po-compare]: https://iscinumpy.gitlab.io/post/comparing-cli11-and-boostpo/
|
||||
@ -452,3 +453,5 @@ CLI11 was developed at the [University of Cincinnati] to support of the [GooFit]
|
||||
[Awesome C++]: https://github.com/fffaraz/awesome-cpp/blob/master/README.md#cli
|
||||
[CLI]: https://codesynthesis.com/projects/cli/
|
||||
[Single file libs]: https://github.com/nothings/single_file_libs/blob/master/README.md
|
||||
[codacy-badge]: https://api.codacy.com/project/badge/Grade/ac0df3aead2a4421b02070c3f324a0b9
|
||||
[codacy-link]: https://www.codacy.com/app/henryiii/CLI11?utm_source=github.com&utm_medium=referral&utm_content=CLIUtils/CLI11&utm_campaign=Badge_Grade
|
||||
|
@ -166,7 +166,8 @@ class App {
|
||||
///@}
|
||||
|
||||
/// Special private constructor for subcommand
|
||||
App(std::string description_, App *parent) : description_(std::move(description_)), parent_(parent) {
|
||||
App(std::string description_, std::string name, App *parent)
|
||||
: name_(std::move(name)), description_(std::move(description_)), parent_(parent) {
|
||||
// Inherit if not from a nullptr
|
||||
if(parent_ != nullptr) {
|
||||
if(parent_->help_ptr_ != nullptr)
|
||||
@ -193,8 +194,7 @@ class App {
|
||||
///@{
|
||||
|
||||
/// Create a new program. Pass in the same arguments as main(), along with a help string.
|
||||
App(std::string description_ = "", std::string name = "") : App(description_, nullptr) {
|
||||
name_ = name;
|
||||
explicit App(std::string description_ = "", std::string name = "") : App(description_, name, nullptr) {
|
||||
set_help_flag("-h,--help", "Print this help message and exit");
|
||||
}
|
||||
|
||||
@ -643,8 +643,7 @@ class App {
|
||||
|
||||
/// Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag
|
||||
App *add_subcommand(std::string name, std::string description = "") {
|
||||
subcommands_.emplace_back(new App(description, this));
|
||||
subcommands_.back()->name_ = name;
|
||||
subcommands_.emplace_back(new App(description, name, this));
|
||||
for(const auto &subc : subcommands_)
|
||||
if(subc.get() != subcommands_.back().get())
|
||||
if(subc->check_name(subcommands_.back()->name_) || subcommands_.back()->check_name(subc->name_))
|
||||
|
@ -26,7 +26,7 @@ namespace CLI {
|
||||
|
||||
// This is added after the one above if a class is used directly and builds its own message
|
||||
#define CLI11_ERROR_SIMPLE(name) \
|
||||
name(std::string msg) : name(#name, msg, ExitCodes::name) {}
|
||||
explicit name(std::string msg) : name(#name, msg, ExitCodes::name) {}
|
||||
|
||||
/// These codes are part of every error in CLI. They can be obtained from e using e.exit_code or as a quick shortcut,
|
||||
/// int values from e.get_error_code().
|
||||
@ -126,7 +126,7 @@ class BadNameString : public ConstructionError {
|
||||
/// Thrown when an option already exists
|
||||
class OptionAlreadyAdded : public ConstructionError {
|
||||
CLI11_ERROR_DEF(ConstructionError, OptionAlreadyAdded)
|
||||
OptionAlreadyAdded(std::string name)
|
||||
explicit OptionAlreadyAdded(std::string name)
|
||||
: OptionAlreadyAdded(name + " is already added", ExitCodes::OptionAlreadyAdded) {}
|
||||
static OptionAlreadyAdded Requires(std::string name, std::string other) {
|
||||
return OptionAlreadyAdded(name + " requires " + other, ExitCodes::OptionAlreadyAdded);
|
||||
@ -190,13 +190,13 @@ class ConversionError : public ParseError {
|
||||
class ValidationError : public ParseError {
|
||||
CLI11_ERROR_DEF(ParseError, ValidationError)
|
||||
CLI11_ERROR_SIMPLE(ValidationError)
|
||||
ValidationError(std::string name, std::string msg) : ValidationError(name + ": " + msg) {}
|
||||
explicit ValidationError(std::string name, std::string msg) : ValidationError(name + ": " + msg) {}
|
||||
};
|
||||
|
||||
/// Thrown when a required option is missing
|
||||
class RequiredError : public ParseError {
|
||||
CLI11_ERROR_DEF(ParseError, RequiredError)
|
||||
RequiredError(std::string name) : RequiredError(name + " is required", ExitCodes::RequiredError) {}
|
||||
explicit RequiredError(std::string name) : RequiredError(name + " is required", ExitCodes::RequiredError) {}
|
||||
static RequiredError Subcommand(size_t min_subcom) {
|
||||
if(min_subcom == 1)
|
||||
return RequiredError("A subcommand");
|
||||
@ -262,7 +262,7 @@ class INIError : public ParseError {
|
||||
/// Thrown when validation fails before parsing
|
||||
class InvalidError : public ParseError {
|
||||
CLI11_ERROR_DEF(ParseError, InvalidError)
|
||||
InvalidError(std::string name)
|
||||
explicit InvalidError(std::string name)
|
||||
: InvalidError(name + ": Too many positional arguments with unlimited expected args", ExitCodes::InvalidError) {
|
||||
}
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ namespace CLI {
|
||||
|
||||
#define CLI11_VERSION_MAJOR 1
|
||||
#define CLI11_VERSION_MINOR 5
|
||||
#define CLI11_VERSION_PATCH 1
|
||||
#define CLI11_VERSION "1.5.1"
|
||||
#define CLI11_VERSION_PATCH 2
|
||||
#define CLI11_VERSION "1.5.2"
|
||||
|
||||
} // namespace CLI
|
||||
|
@ -12,6 +12,7 @@ from functools import reduce
|
||||
|
||||
includes_local = re.compile(r"""^#include "(.*)"$""", re.MULTILINE)
|
||||
includes_system = re.compile(r"""^#include \<(.*)\>$""", re.MULTILINE)
|
||||
version_finder = re.compile(r"""^#define CLI11_VERSION \"(.*)\"$""", re.MULTILINE)
|
||||
verbatim_tag_str = r"""
|
||||
^ # Begin of line
|
||||
[^\n^\[]+ # Some characters, not including [ or the end of a line
|
||||
@ -30,14 +31,20 @@ DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
class HeaderFile(object):
|
||||
TAG = "Unknown git revision"
|
||||
LICENSE = "// BSD 3 clause"
|
||||
VERSION = "Unknown"
|
||||
|
||||
def __init__(self, base, inc):
|
||||
with open(os.path.join(base, inc)) as f:
|
||||
inner = f.read()
|
||||
|
||||
version = version_finder.search(inner)
|
||||
if version:
|
||||
self.__class__.VERSION = version.groups()[0]
|
||||
|
||||
# add self.verbatim
|
||||
if 'CLI11:verbatim' in inner:
|
||||
self.verbatim = ["\n\n// Verbatim copy from {}".format(inc)]
|
||||
self.verbatim = ["\n\n// Verbatim copy from {}:".format(inc)]
|
||||
self.verbatim += verbatim_all.findall(inner)
|
||||
inner = verbatim_all.sub("", inner)
|
||||
else:
|
||||
@ -45,7 +52,7 @@ class HeaderFile(object):
|
||||
|
||||
self.headers = set(includes_system.findall(inner))
|
||||
|
||||
self.body = '\n// From {}\n\n'.format(inc) + inner[inner.find('namespace'):]
|
||||
self.body = '\n// From {}:\n\n'.format(inc) + inner[inner.find('namespace'):]
|
||||
|
||||
def __add__(self, other):
|
||||
out = copy(self)
|
||||
@ -66,12 +73,18 @@ class HeaderFile(object):
|
||||
return '''\
|
||||
#pragma once
|
||||
|
||||
// Distributed under the 3-Clause BSD License. See accompanying
|
||||
// file LICENSE or https://github.com/CLIUtils/CLI11 for details.
|
||||
|
||||
// This file was generated using MakeSingleHeader.py in CLI11/scripts
|
||||
// CLI11: Version {self.VERSION}
|
||||
// Originally designed by Henry Schreiner
|
||||
// https://github.com/CLIUtils/CLI11
|
||||
//
|
||||
// This is a standalone header file generated ny MakeSingleHeader.py in CLI11/scripts
|
||||
// from: {self.TAG}
|
||||
// This has the complete CLI library in one file.
|
||||
//
|
||||
// From LICENSE:
|
||||
//
|
||||
{self.LICENSE}
|
||||
|
||||
// Standard combined includes:
|
||||
|
||||
{self.header_str}
|
||||
{self.verbatim_str}
|
||||
@ -82,12 +95,16 @@ class HeaderFile(object):
|
||||
def MakeHeader(output, main_header, include_dir = '../include'):
|
||||
# Set tag if possible to class variable
|
||||
try:
|
||||
HeaderFile.TAG = check_output(['git', 'describe', '--tags', '--always'], cwd=str(DIR)).decode("utf-8")
|
||||
HeaderFile.TAG = check_output(['git', 'describe', '--tags', '--always'], cwd=str(DIR)).decode("utf-8").strip()
|
||||
except CalledProcessError:
|
||||
pass
|
||||
|
||||
base_dir = os.path.abspath(os.path.join(DIR, include_dir))
|
||||
main_header = os.path.join(base_dir, main_header)
|
||||
licence_file = os.path.abspath(os.path.join(DIR, '../LICENSE'))
|
||||
|
||||
with open(licence_file) as f:
|
||||
HeaderFile.LICENSE = ''.join('// ' + line for line in f)
|
||||
|
||||
with open(main_header) as f:
|
||||
header = f.read()
|
||||
|
@ -26,7 +26,7 @@ class TempFile {
|
||||
std::string _name;
|
||||
|
||||
public:
|
||||
TempFile(std::string name) : _name(name) {
|
||||
explicit TempFile(std::string name) : _name(name) {
|
||||
if(!CLI::NonexistentPath(_name).empty())
|
||||
throw std::runtime_error(_name);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user