From 193c6888e9a50d4aae967b693664c7e3fa41901a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damien=20Nad=C3=A9?= Date: Wed, 3 Mar 2021 01:42:28 +0100 Subject: [PATCH 01/13] split argsparse source code into multiple files for better maintenance --- argsparse.sh | 1656 ----------------------------------- src/00_head | 312 +++++++ src/10_utils | 92 ++ src/15_misc | 33 + src/19_option-property | 141 +++ src/20_declaration | 121 +++ src/30_types | 91 ++ src/40_usage | 227 +++++ src/60_option-value-setting | 160 ++++ src/65_params | 71 ++ src/70_parsing | 366 ++++++++ src/80_post-parsing | 62 ++ src/95_help-option | 28 + src/99_main | 11 + 14 files changed, 1715 insertions(+), 1656 deletions(-) delete mode 100644 argsparse.sh create mode 100644 src/00_head create mode 100644 src/10_utils create mode 100644 src/15_misc create mode 100644 src/19_option-property create mode 100644 src/20_declaration create mode 100644 src/30_types create mode 100644 src/40_usage create mode 100644 src/60_option-value-setting create mode 100644 src/65_params create mode 100644 src/70_parsing create mode 100644 src/80_post-parsing create mode 100644 src/95_help-option create mode 100644 src/99_main diff --git a/argsparse.sh b/argsparse.sh deleted file mode 100644 index 9f4e9d2..0000000 --- a/argsparse.sh +++ /dev/null @@ -1,1656 +0,0 @@ -#!/usr/bin/env bash -# -*- tab-width: 4; encoding: utf-8; -*- -# -######### -# License: -# -# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE -# Version 2, December 2004 -# -# Copyright (C) 2004 Sam Hocevar -# -# Everyone is permitted to copy and distribute verbatim or modified -# copies of this license document, and changing it is allowed as long -# as the name is changed. -# -# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE -# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -# -# 0. You just DO WHAT THE FUCK YOU WANT TO. -# -######### -# -## @file -## @author Damien Nadé -## @copyright WTFPLv2 -## @version 1.8 -## @brief Bash Argsparse Library -## @details -## @par URL -## https://github.com/Anvil/bash-argsparse @n -## -## @par Purpose -## -## To replace the option-parsing and usage-describing functions -## commonly rewritten in all scripts. -## -## @note -## This library is implemented for bash version 4. Prior versions of -## bash will fail at interpreting that code. -## @note -## The extglob shell option will be enabled and posix mode will be -## disabled when loading the library. Changing those settings -## afterwards will make the library execution fail. -## -## @par Usage -## Use the argsparse_use_option() function to declare your options with -## their single letter counterparts, along with their description. -## -## @par -## The argsparse_use_option() syntax is: -## -## @code -## argsparse_use_option "optstring" "option description string" \ -## [ "property" ... ] [ "optional default value" ] -## @endcode -## -## -## @par -## An "optstring" is of the form "som=estring:". This would declare a -## long option named somestring. The ending ":" is optional and, if -## present, means the long option expects a value on the command -## line. The "=" char is also optional and means the immediatly -## following letter is the short single-letter equivalent option of -## --something. -## -## @par -## The "something" string must only contains ASCII -## letters/numbers/dash/underscore characters. -## -## @note -## What is referred later as "option" or "option name" (or even "long -## option name") is the optstring without the ':' and '=' characters. -## -## -## -## @par Options may have properties. -## -## Properties are set either at option declarations through the -## argsparse_use_option() function, or using the -## argsparse_set_option_property() function -## -## The currently supported properties are: -## -## - "hidden" @n -## An hidden option will not be shown in usage. -## -## - "mandatory" @n -## An option marked as mandatory is required on the command line. If -## a mandatory option is omited by the user, usage() will be -## triggered by argsparse_parse_options(). -## -## - "value" @n -## On the command line, the option will require a value. -## Same effect if you end your optstring with a ':' char. -## -## - "default:" @n -## The default value for the option. -## -## - "short:" @n -## The short single-letter equivalent of the option. -## -## - "type:" @n -## Give a type to the option value. User input value will be checked -## against built-in type verifications _or_ the -## "check_type_" function. You cannot override a built-in -## type. Built-in types are: -## - file -## - directory -## - pipe -## - terminal -## - socket -## - link -## - char -## - unsignedint -## - uint -## - integer -## - int -## - hexa -## - ipv4 -## - ipv6 -## - ip -## - hostname -## - host -## - portnumber -## - port -## - username -## - group -## - date -## . -## -## - "exclude: