Package: cliparse
Cliparse (CLI with ArgumentParser)Cliparseis a framework to make CLI with'Argparse'and'Cmd'ConceptThere are times when it is necessary that to provide a command line client likeMySQL Command Line Client.$mysql-uroot-p

Type'help;',or'\h'forhelp.Type'\C'tocleancurrentinputstatement.

mysql>usetest_db;Some of legacy CLI framework we could have chosen are not easy to extend or written in low productivity languages.Cliparseis written with some of the most used modules in Python.Cmdis a very common module of python for making CLI application. It provides a prompt to gets command input from user, tab auto completion, help message or usage. Actually, It's already super easy enough to make CLI applications withCmd.Argparseis an argument parser in command line interface. It parses options and arguments. With some short options, we can check validations which several types of arguments such as string or integer and boolean.parser=ArgumentParser(prog='',description='description',epilog='end of description',)sub_parser=parser.add_subparsers(dest='sub_parser')# Setting# ==========================================================================setting_parser=sub_parser.add_parser('setting',help='Setting Command')# Setting - DB Initializing# ==========================================================================setting_init_db_parser=setting_parser.add_subparsers(dest='init',help='Initialize the database')init_db_parser=setting_init_db_parser.add_parser(name='initialize-db',help='Initialize database')init_db_parser.add_argument('-d','--init-db',action='store_true',help='initialize database.')init_db_parser.add_argument('-m','--dummy-members',action='store_true',help='insert dummy members.')init_db_parser.add_argument('-b','--dummy-books',action='store_true',help='insert dummy books.')init_db_parser.add_argument('-r','--dummy-rental',action='store_true',help='insert dummy rental.')init_db_parser.set_defaults(func=initialize_db)These awesome modules are already used for a long time and easy to find its usage on web sites.WhatCliparsedoes is to read user's argument parsers, to print the parser groups and parameters for running its function, and to make completing command line when tab. And print a result data of the function defined at the parser with some simple table viewer.Cliparseis very simple. That's all it does.FeaturesAll command line input validation checking byArgparseEasy command line input with tab auto completionInstallation$pipinstallcliparseor$pythonsetup.pyinstallRunning$python-mcliparse./sample_cli/cli.pyRunning with dockerIf you use docker, you can try it like below.Build$dockerbuild-tcliparse:latest.or$docker-composebuildRunningthe volume option for mounting host directory where the sample cli is.$dockerrun-it-v$(pwd):/root--rmcliparsesample_cli/cli.pyor$docker-composerun-v$(pwd):/root--rmcliparsesample_cli/cli.pysample_cli/cli.pyThis sample cli file is also able to run withoutCliparse.pythonsample_cli/cli.py-hSampleThere is a simple sample cli which is able to try basic CRUD. It is in the directory namedsample_cli/cli.py. Please run command below and try to edit as you want.Things you can doHelpUse help command to learn more about a command's usage.# Help(Cmd)helpDocumentedcommands(typehelp<topic>):========================================helpmanagersetting(Cmd)manager-h
usage:manager[-h]{book}...

positionalarguments:{book}Initializethedatabasebooksettingcommandoptionalarguments:-h,--helpshowthishelpmessageandexit(Cmd)managerbook-h
usage:managerbook[-h][-r|-t]{insert,update,delete}...

positionalarguments:{insert,update,delete}optionalarguments:-h,--helpshowthishelpmessageandexit-r,--raw-datashowthedataasraw-t,--simple-tableshowthedatawithsimpletableTapping tab keyUse Tab key to autocomplete commands in the command line. It also shows a list of commands you can use.Choosing presentation style# show --raw-data(Cmd)managerbook--raw-data[{"author":"John Doe","title":"How to learn speaking English","publisher":"Magic House"},{"author":"George Orwell","title":"1984","publisher":"Motihari"}]# show data with simple table(Cmd)managerbook--simple-table||author|title|publisher||----+---------------+-------------------------------+-------------||0|JohnDoe|HowtolearnspeakingEnglish|MagicHouse||1|GeorgeOrwell|1984|Motihari|ContributesRunning as development modeYou don't need to build the docker image every time whenever source code changes.docker-compose-fdocker-compose.dev.ymlrun--rmcliparse