Package: clinterfacer
TheclinterfacerframeworkThis framework aims to simplify the creation of Command-Line Interfaces (CLIs) using python.InstallationTo install theclinterfacerframework usingpiponly, enter the following command:pipinstallclinterfacer==1.3.0However, if you are usingpipenv, enter the following command in the root of your project.pipenvinstallclinterfacer==1.3.0UsageAfter installation, it must be exist the follow files and folders in your project:clinterfaced
├──clinterfaced*
│├──commands*
││├──build.py
││├──config.py
││├──deploy.py
││├──doc.py
││├──get_param.py
││├──__init__.py*
││└──train.py
│├──__init__.py*
│├──__main__.py*
│├──resources**
││├──__init__.py**
││└──logging.ini**
│├──subparsers*
││├──build.py
││├──config.py
││├──deploy.py
││├──doc.py
││├──get_param.py
││├──__init__.py*
││└──train.py
│└──utils.py
├──Makefile
├──Pipfile
├──README.md*
└──setup.py*All the above files and folders ending with*are expected by theclinterfacerframework. However, all the above files and folders ending with**are opitional and are used by theclinterfacerframework to load the desired logging configuration. The remaining files and folders were merely used for exemplifying.Thesetup.pyfileThere is a template for thesetup.pyfile bellow.#!/usr/bin/env python# -*- coding: utf-8 -*-"""This file is used to install the clinterfaced package."""# standard library(ies)importpathlibasplimporttyping# 3rd party package(s)importsetuptools# local source(s)importclinterfacedaspackagedefread(path:typing.Union[str,pl.Path],encoding:str='utf-8')->str:ifisinstance(path,str):path=pl.Path(path)returnpath.read_text(encoding)ifpath.exists()else''readme=pathlib.Path('./README.md')metadata={'name':package.__name__,'version':package.__version__,'author':package.__author__,'author_email':package.__email__,'maintainer':package.__maintainer__,'maintainer_email':package.__email__,'description':package.__description__,'long_description':read(readme),'long_description_content_type':'text/markdown','url':package.__url__,'packages':setuptools.find_packages(),'include_package_data':True,'install_requires':['clinterfacer==1.3.0',],'entry_points':{'console_scripts':[f'{package.__name__}={package.__name__}.__main__:main',],},'classifiers':['Programming Language :: Python :: 3','Operating System :: OS Independent',],}if__name__=='__main__':setuptools.setup(**metadata)The__init__.pyfile#!/usr/bin/env python"""__init__.py: This script includes all the project's metadata."""__authors__=('Adriano Henrique Rossette Leite',)__email__=('adrianohrl@gmail.com',)__maintainer__=('Adriano Henrique Rossette Leite',)__copyright__=''__credits__=[]__license__=''__version__='0.0.0'# this information should be altered only by the bumpversion tool__status__='Development'# should typically be one of 'Prototype', 'Development',__description__='This package uses the clinterfacer framework.'__url__='https://gitlab.com/adrianohrl/clinterfaced'__author__=', '.join(__author__)__email__=', '.join(__email__)__maintainer__=', '.join(__maintainer__)options=['Development','Prototype','Production',]if__status__isnotinoptions:raiseException(f'Invalid __status__:{__status__}. It should typically be one of the following:{options}')The__main__.pyfile#!/usr/bin/env python"""This is the main script of the clinterfaced package."""# standard library(ies)importsys# 3rd party package(s)importclinterfacerdefmain()->int:cli=clinterfacer.CLI()returncli.main()if__name__=='__main__':returnsys.exit(main())ThecommandsfolderThe script below is an example of the implementation of a command named asget-param.#!/usr/bin/env python# -*- coding: utf-8 -*-"""This is the main script of the clinterfaced's get-param command."""# standard library(ies)importargparseimportloggingimportsys# local source(s)fromclinterfaced.subparsers.get_paramimportparse_argslogger=logging.getLogger(__name__)parameters={'framework':'CLInterfacer',}defmain(args:argparse.Namespace)->None:logger.info(f'Getting parameter the clinterfaced\'s{args.parameter}paramenter ...')logger.info(f'Value for the{args.parameter}parameter:\'{parameters[args.parameter]}\'')if__name__=='__main__':args=parse_args()sys.exit(main(args))ThesubparsersfolderThe script below is an example of the definition of the arguments of a command named asget-param.#!/usr/bin/env python# -*- coding: utf-8 -*-"""This script defines the clinterfaced's get-param subparser."""# standard library(ies)importargparse# 3rd party package(s)fromclinterfacerimportclidefadd_parser(subparsers:argparse._SubParsersAction)->None:parser=subparsers.add_parser('get-param',help='This is the get-param command of the clinterfaced package',prog='clinterfaced get-param',description='This command is the get-param one.',)add_arguments(parser)defadd_arguments(parser:argparse.ArgumentParser)->None:parser.add_argument('parameter',help='Specifies the name of the desired paramenter.',metavar='PARAMETER',)defparse_args()->argparse.Namespace:parser=argparse.ArgumentParser()add_arguments(parser)args=parser.parse_args()cli.setup()returnargsInstalling the packagepipenvinstallclinterfacerEntering the commands in terminalpipenvshell
clinterfacedbuild
clinterfacedconfig-f./build.txt
clinterfacedtrain-t0.6
clinterfaceddeploy
clinterfaceddoc-bhtmlexit# or Ctrl+DReleasinggitcheckoutmaster
gitpull
gitmerge--no-ffnew-feature
bumpversion[major|minor|patch]gitpushoriginmaster--tagspythonsetup.pysdistbdist_wheel
tartzfdist/clinterfacer-1.3.0.tar.gztwinecheckdist/*
twineupload--verbose--repository-urlhttps://test.pypi.org/legacy/dist/*
twineupload--verbosedist/*