From c730062db3b2dacadf16d916fdb3840ff257b957 Mon Sep 17 00:00:00 2001 From: jaska Date: Sun, 29 Sep 2019 11:37:51 +0100 Subject: [PATCH 1/4] Option grouping (#338) * :wheel_chair: group the ever growing cli options * :books: update change log * :books: minor update on the help text for -c * :books: pump up the version number --- .moban.cd/changelog.yml | 6 +++ .moban.cd/moban.yml | 4 +- CHANGELOG.rst | 8 ++++ docs/conf.py | 2 +- moban/_version.py | 2 +- moban/constants.py | 2 +- moban/main.py | 91 ++++++++++++++++++++++------------------- setup.py | 2 +- 8 files changed, 70 insertions(+), 47 deletions(-) diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index b3584f87..34a1b424 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -1,6 +1,12 @@ name: moban organisation: moremoban releases: + - changes: + - action: Updated + details: + - "Command options have been grouped. --template_type became --template-type" + date: tbd + version: 0.6.4 - changes: - action: Added details: diff --git a/.moban.cd/moban.yml b/.moban.cd/moban.yml index 5853522c..2432172b 100644 --- a/.moban.cd/moban.yml +++ b/.moban.cd/moban.yml @@ -4,8 +4,8 @@ organisation: moremoban author: C. W. contact: wangc_2011@hotmail.com license: MIT -version: 0.6.3 -current_version: 0.6.3 +version: 0.6.4 +current_version: 0.6.4 release: 0.6.3 branch: master master: index diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bf1a2951..f973bb29 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Change log ================================================================================ +0.6.4 - tbd +-------------------------------------------------------------------------------- + +Updated +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +#. Command options have been grouped. --template_type became --template-type + 0.6.3 - 25.09.2019 -------------------------------------------------------------------------------- diff --git a/docs/conf.py b/docs/conf.py index 7378f931..5c3cd9e0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -25,7 +25,7 @@ copyright = '2017-2019 Onni Software Ltd.' author = 'C. W.' # The short X.Y version -version = '0.6.3' +version = '0.6.4' # The full version, including alpha/beta/rc tags release = '0.6.3' diff --git a/moban/_version.py b/moban/_version.py index ed642873..a83896a5 100644 --- a/moban/_version.py +++ b/moban/_version.py @@ -1,2 +1,2 @@ -__version__ = "0.6.3" +__version__ = "0.6.4" __author__ = "C. W." diff --git a/moban/constants.py b/moban/constants.py index d726f084..9b4277e5 100644 --- a/moban/constants.py +++ b/moban/constants.py @@ -7,7 +7,7 @@ # Configurations PROGRAM_NAME = "moban" PROGRAM_DESCRIPTION = ( - "Yet another jinja2 cli command for static " + "text generation" + "Static text generator using any template, any data and any location." ) DEFAULT_YAML_SUFFIX = ".yml" # .moban.yml, default moban configuration file diff --git a/moban/main.py b/moban/main.py index 96f3e569..e855d5a5 100644 --- a/moban/main.py +++ b/moban/main.py @@ -89,80 +89,89 @@ def create_parser(): prog=constants.PROGRAM_NAME, description=constants.PROGRAM_DESCRIPTION ) parser.add_argument( - "-cd", - "--%s" % constants.LABEL_CONFIG_DIR, - help="the directory for configuration file lookup", + "-c", "--%s" % constants.LABEL_CONFIG, help="the data file" + ) + parser.add_argument( + "-t", "--%s" % constants.LABEL_TEMPLATE, help="the template file" ) parser.add_argument( - "-c", "--%s" % constants.LABEL_CONFIG, help="the dictionary file" + "-o", "--%s" % constants.LABEL_OUTPUT, help="the output file" ) parser.add_argument( + constants.POSITIONAL_LABEL_TEMPLATE, + metavar="template", + type=str, + nargs="?", + help="string templates", + ) + advanced = parser.add_argument_group( + "Advanced options", "For better control" + ) + advanced.add_argument( "-td", "--%s" % constants.LABEL_TMPL_DIRS, nargs="*", - help="the directories for template file lookup", + help="add more directories for template file lookup", ) - parser.add_argument( - "-t", "--%s" % constants.LABEL_TEMPLATE, help="the template file" + advanced.add_argument( + "-cd", + "--%s" % constants.LABEL_CONFIG_DIR, + help="the directory for configuration file lookup", ) - parser.add_argument( - "-o", "--%s" % constants.LABEL_OUTPUT, help="the output file" + advanced.add_argument( + "-m", "--%s" % constants.LABEL_MOBANFILE, help="custom moban file" ) - parser.add_argument( - "--%s" % constants.LABEL_TEMPLATE_TYPE, + advanced.add_argument( + "-g", "--%s" % constants.LABEL_GROUP, help="a subset of targets" + ) + advanced.add_argument( + "--%s" % constants.LABEL_TEMPLATE_TYPE.replace("_", "-"), help="the template type, default is jinja2", ) - parser.add_argument( + advanced.add_argument( + "-d", + "--%s" % constants.LABEL_DEFINE, + nargs="+", + help=( + "to supply additional or override predefined variables," + + " format: VAR=VALUEs" + ), + ) + advanced.add_argument( + "-e", + "--%s" % constants.LABEL_EXTENSION, + nargs="+", + help="to to TEMPLATE_TYPE=EXTENSION_NAME", + ) + advanced.add_argument( "-f", action="store_true", dest=constants.LABEL_FORCE, default=False, help="force moban to template all files despite of .moban.hashes", ) - parser.add_argument( + developer = parser.add_argument_group( + "Developer options", "For debugging and development" + ) + developer.add_argument( "--%s" % constants.LABEL_EXIT_CODE, action="store_true", dest=constants.LABEL_EXIT_CODE, default=False, help="tell moban to change exit code", ) - parser.add_argument( - "-m", "--%s" % constants.LABEL_MOBANFILE, help="custom moban file" - ) - parser.add_argument( - "-g", "--%s" % constants.LABEL_GROUP, help="a subset of targets" - ) - parser.add_argument( - constants.POSITIONAL_LABEL_TEMPLATE, - metavar="template", - type=str, - nargs="?", - help="string templates", - ) - parser.add_argument( + developer.add_argument( "-V", "--%s" % constants.LABEL_VERSION, action="version", version="%(prog)s {v}".format(v=__version__), ) - parser.add_argument( + developer.add_argument( "-v", action="count", dest=constants.LABEL_VERBOSE, default=0, - help="show verbose", - ) - parser.add_argument( - "-d", - "--%s" % constants.LABEL_DEFINE, - nargs="+", - help="to take a list of VAR=VALUEs", - ) - parser.add_argument( - "-e", - "--%s" % constants.LABEL_EXTENSION, - nargs="+", - help="to add an extension to TEMPLATE_TYPE=EXTENSION_NAME", + help="show verbose, try -v, -vv", ) return parser diff --git a/setup.py b/setup.py index 08b37c05..f7482386 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ NAME = "moban" AUTHOR = "C. W." -VERSION = "0.6.3" +VERSION = "0.6.4" EMAIL = "wangc_2011@hotmail.com" LICENSE = "MIT" ENTRY_POINTS = { From 7bf40a5e6446dec2829de5014fbb7683727fdf33 Mon Sep 17 00:00:00 2001 From: chfw Date: Fri, 4 Oct 2019 20:27:18 +0100 Subject: [PATCH 2/4] :books: update change log --- .moban.cd/changelog.yml | 2 +- .moban.cd/moban.yml | 4 ++-- CHANGELOG.rst | 2 +- README.rst | 53 +++++++++++++++++++++++++---------------- docs/conf.py | 2 +- min_requirements.txt | 2 +- requirements.txt | 2 +- setup.py | 8 +++---- 8 files changed, 43 insertions(+), 32 deletions(-) diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index 34a1b424..f7fafe85 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -5,7 +5,7 @@ releases: - action: Updated details: - "Command options have been grouped. --template_type became --template-type" - date: tbd + date: 4.10.2019 version: 0.6.4 - changes: - action: Added diff --git a/.moban.cd/moban.yml b/.moban.cd/moban.yml index 2432172b..52dba2a1 100644 --- a/.moban.cd/moban.yml +++ b/.moban.cd/moban.yml @@ -6,7 +6,7 @@ contact: wangc_2011@hotmail.com license: MIT version: 0.6.4 current_version: 0.6.4 -release: 0.6.3 +release: 0.6.4 branch: master master: index command_line_interface: "moban" @@ -27,7 +27,7 @@ dependencies: - appdirs>=1.4.3 - crayons>= 0.1.0 - fs>=2.4.11 - - gitfs2>=0.0.1 + - gitfs2>=0.0.2 - pypifs>=0.0.1 - jinja2-fsloader>=0.2.0 description: Yet another jinja2 cli command for static text generation diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f973bb29..b8039aff 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ Change log ================================================================================ -0.6.4 - tbd +0.6.4 - 4.10.2019 -------------------------------------------------------------------------------- Updated diff --git a/README.rst b/README.rst index bf60eba3..afbee3a9 100644 --- a/README.rst +++ b/README.rst @@ -171,51 +171,62 @@ Then you can access your files in s3 bucket: Where the configuration sits in a s3 bucket, the output is a file in a zip. The content of s3data.yaml is:: hello: world - -Usage + + +CLI documentation ================================================================================ .. code-block:: bash - - usage: moban [-h] [-cd CONFIGURATION_DIR] [-c CONFIGURATION] - [-td [TEMPLATE_DIR [TEMPLATE_DIR ...]]] [-t TEMPLATE] [-o OUTPUT] - [--template_type TEMPLATE_TYPE] [-f] [--exit-code] [-m MOBANFILE] - [-g GROUP] [-V] [-v] [-D DEFINE [DEFINE ...]] + usage: moban [-h] [-c CONFIGURATION] [-t TEMPLATE] [-o OUTPUT] + [-td [TEMPLATE_DIR [TEMPLATE_DIR ...]]] [-cd CONFIGURATION_DIR] + [-m MOBANFILE] [-g GROUP] [--template-type TEMPLATE_TYPE] + [-d DEFINE [DEFINE ...]] [-e EXTENSION [EXTENSION ...]] [-f] + [--exit-code] [-V] [-v] [template] - Yet another jinja2 cli command for static text generation + Static text generator using any template, any data and any location. positional arguments: template string templates optional arguments: -h, --help show this help message and exit - -cd CONFIGURATION_DIR, --configuration_dir CONFIGURATION_DIR - the directory for configuration file lookup -c CONFIGURATION, --configuration CONFIGURATION - the dictionary file - -td [TEMPLATE_DIR [TEMPLATE_DIR ...]], --template_dir [TEMPLATE_DIR [TEMPLATE_DIR ...]] - the directories for template file lookup + the data file -t TEMPLATE, --template TEMPLATE the template file -o OUTPUT, --output OUTPUT the output file - --template_type TEMPLATE_TYPE - the template type, default is jinja2 - -f force moban to template all files despite of - .moban.hashes - --exit-code tell moban to change exit code + + Advanced options: + For better control + + -td [TEMPLATE_DIR [TEMPLATE_DIR ...]], --template_dir [TEMPLATE_DIR [TEMPLATE_DIR ...]] + add more directories for template file lookup + -cd CONFIGURATION_DIR, --configuration_dir CONFIGURATION_DIR + the directory for configuration file lookup -m MOBANFILE, --mobanfile MOBANFILE custom moban file -g GROUP, --group GROUP a subset of targets - -V, --version show program's version number and exit - -v show verbose + --template-type TEMPLATE_TYPE + the template type, default is jinja2 -d DEFINE [DEFINE ...], --define DEFINE [DEFINE ...] - to take a list of VAR=VALUEs + to supply additional or override predefined variables, + format: VAR=VALUEs + -e EXTENSION [EXTENSION ...], --extension EXTENSION [EXTENSION ...] + to to TEMPLATE_TYPE=EXTENSION_NAME + -f force moban to template all files despite of + .moban.hashes + + Developer options: + For debugging and development + --exit-code tell moban to change exit code + -V, --version show program's version number and exit + -v show verbose, try -v, -vv Exit codes -------------------------------------------------------------------------------- diff --git a/docs/conf.py b/docs/conf.py index 5c3cd9e0..7f2dd23d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,7 @@ # The short X.Y version version = '0.6.4' # The full version, including alpha/beta/rc tags -release = '0.6.3' +release = '0.6.4' # -- General configuration --------------------------------------------------- diff --git a/min_requirements.txt b/min_requirements.txt index 8275da87..098725ab 100644 --- a/min_requirements.txt +++ b/min_requirements.txt @@ -7,6 +7,6 @@ lml==0.0.9 appdirs==1.4.3 crayons== 0.1.0 fs==2.4.11 -gitfs2==0.0.1 +gitfs2==0.0.2 pypifs==0.0.1 jinja2-fsloader==0.2.0 diff --git a/requirements.txt b/requirements.txt index 45aaaec7..d5e54712 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,6 @@ lml>=0.0.9 appdirs>=1.4.3 crayons>= 0.1.0 fs>=2.4.11 -gitfs2>=0.0.1 +gitfs2>=0.0.2 pypifs>=0.0.1 jinja2-fsloader>=0.2.0 diff --git a/setup.py b/setup.py index f7482386..15917f45 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,7 @@ "Yet another jinja2 cli command for static text generation" ) URL = "https://github.com/moremoban/moban" -DOWNLOAD_URL = "%s/archive/0.6.3.tar.gz" % URL +DOWNLOAD_URL = "%s/archive/0.6.4.tar.gz" % URL FILES = ["README.rst", "CONTRIBUTORS.rst", "CHANGELOG.rst"] KEYWORDS = [ "python", @@ -81,7 +81,7 @@ "appdirs>=1.4.3", "crayons>= 0.1.0", "fs>=2.4.11", - "gitfs2>=0.0.1", + "gitfs2>=0.0.2", "pypifs>=0.0.1", "jinja2-fsloader>=0.2.0", ] @@ -97,8 +97,8 @@ } # You do not need to read beyond this line PUBLISH_COMMAND = "{0} setup.py sdist bdist_wheel upload -r pypi".format(sys.executable) -GS_COMMAND = ("gs moban v0.6.3 " + - "Find 0.6.3 in changelog for more details") +GS_COMMAND = ("gs moban v0.6.4 " + + "Find 0.6.4 in changelog for more details") NO_GS_MESSAGE = ("Automatic github release is disabled. " + "Please install gease to enable it.") UPLOAD_FAILED_MSG = ( From abd1ea95aedf2cab69e92b5a8f43ac553da6e085 Mon Sep 17 00:00:00 2001 From: chfw Date: Fri, 4 Oct 2019 20:27:45 +0100 Subject: [PATCH 3/4] :books: update change log --- .moban.cd/changelog.yml | 1 + CHANGELOG.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index f7fafe85..a96db7ae 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -5,6 +5,7 @@ releases: - action: Updated details: - "Command options have been grouped. --template_type became --template-type" + - "Increment gitfs2 to version 0.0.2" date: 4.10.2019 version: 0.6.4 - changes: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b8039aff..b78c0247 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,7 @@ Updated ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #. Command options have been grouped. --template_type became --template-type +#. Increment gitfs2 to version 0.0.2 0.6.3 - 25.09.2019 -------------------------------------------------------------------------------- From b24f4cb8b99e734c31fc004c1f8ad65fe4721ce9 Mon Sep 17 00:00:00 2001 From: chfw Date: Fri, 4 Oct 2019 20:29:47 +0100 Subject: [PATCH 4/4] :books: update issue reference --- .moban.cd/changelog.yml | 2 +- CHANGELOG.rst | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.moban.cd/changelog.yml b/.moban.cd/changelog.yml index a96db7ae..a0dd2995 100644 --- a/.moban.cd/changelog.yml +++ b/.moban.cd/changelog.yml @@ -5,7 +5,7 @@ releases: - action: Updated details: - "Command options have been grouped. --template_type became --template-type" - - "Increment gitfs2 to version 0.0.2" + - "Increment gitfs2 to version 0.0.2. `gitfs#4`" date: 4.10.2019 version: 0.6.4 - changes: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b78c0247..972070f8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,7 +8,8 @@ Updated ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #. Command options have been grouped. --template_type became --template-type -#. Increment gitfs2 to version 0.0.2 +#. Increment gitfs2 to version 0.0.2. `gitfs#4 + `_ 0.6.3 - 25.09.2019 --------------------------------------------------------------------------------