Package: pype-cli
pype-cliA command-line tool for command-line toolsIn a nutshellpype-cliis a command-line tool to manage sets of other command-line tools. It simplifies the creation, orchestration and access of Python scripts that you require for your development work, process automation, etc.QuickstartInstallpype-cliviapip3 install --user pype-cli. This will install the commandpypefor the current userTo use an alternative name you need to install from source viaPYPE_CUSTOM_SHELL_COMMAND=my_cmd_name python3 setup.py install --userRunpype pype.config shell-installand open a new shell to activate shell completionCreate a newpluginin your home folder:pype pype.config plugin-register --create --name my-plugin --path ~/Create a samplepypefor your plugin:pype my-plugin --create-pype my-pypeRun yourpype:pype my-plugin my-pypeShow and edit the templatepypeyou've just created:pype my-plugin --open-pype my-pypeYou'll find more information on the commands in the sections below.Usagepype-clibuilds uponpluginsandpypes. Apypeis a single Python script whereas apluginis essentially a Python module that extenspype-cliwith a collection ofpypes.pype-cliships with one built-inplugincalledpype.configthat is used to configurepype-cli. All of the required information will be stored to a local JSON-configuration file that defaults to~/.pype-cli/config.json. To configure a custom configuration folder use the environment variablePYPE_CONFIG_FOLDER. For example to use/path/to/pype-cli/config.jsonas configuration folder/file put into your~/.bashrcfile:export PYPE_CONFIG_FOLDER=/path/to/pype-cli.Basic operationsList all availablepypes:pype --list-pypesOpenpype-cli's configuration file:pype --open-configRefer topype ... --helpfor further information on the command-lineFor all options you will find a short variant such as-hfor--helporpype -linstead ofpype --list-pypes. They are omitted here for better readability.Install pype autocompletion and aliasespype-cli's main benefit is that is is extendable with custompluginsand that it will allow you to immediatelly browse and use newly created and existingplugins/pypesby using the<TAB>key and by configuring shortaliases. To enable the functionality it is required to install a source-script to your shell's rc-file that will be executed everytime you open a shell.Runpype pype.config shell-installRunpype pype.config shell-uninstallto remove if necessaryIf you want to use one-tab completion (instead of two tab presses) you can add the following section to your.bashrcfile:bind'set show-all-if-ambiguous on'bind'set completion-ignore-case on'For.zshrcapply instead:unsetoptlistambiguousUn-/register pluginsRegister an existingplugin:pype pype.config plugin-register --name myplugin --path ~/pype_plugins(mypluginis a Python module with at least an__init__.pyfile and~/pype_pluginsa folder where thepluginis stored)On-the-fly create and register a newplugin:pype pype.config plugin-register --create --name myplugin --path ~/pype_pluginsUnregister (but not delete) aplugin:pype pype.config plugin-unregister --name mypluginCreate, open and delete pypesTo create a new pype you need to decide to which plugin you want to add the pype, e.g.,myplugin.Create a newpypefrom a template:pype myplugin --create mypypeCreate a newpypefrom a template with less boilerplate:pype myplugin --minimal --create mypypeCreate a newpypefrom minimal template and open immediately:pype myplugin --minimal --edit --create mypypeOpen apypein your default editor:pype myplugin --open-pype mypypeDelete apype:pype myplugin --delete-pype mypypeUn-/register aliasesIf you have selected apypefrom apluginyou can setaliasesfor it. Afterwards you need to start a new shell session or source your rc-file to activate thealiases. Newaliasesare stored in the configuration file.Register analias:pype --alias-register mm myplugin mypype→alias mm="pype myplugin mypype"Register analias with options:pype --alias-register mm myplugin mypype --option opt1 --toggle→alias mm="pype myplugin mypype --option opt1 --toggle"Unregister analias:pype --alias-unregister mmList all avaliablealiases:pype --aliasesGlobal logging configurationpype-clicontains a built-in logger setup. To configure it use thepypepype pype.config logger. In yourpypesyou can use it right awaylike in the provided example.Enable/disable global logging:pype pype.config logger enable/disablePrint current configuration:pype pype.config logger print-configSet logging folder:pype pype.config logger set-directory /your/login/folderSet logging level:pype pype.config logger set-level DEBUGSet logging pattern:pype pype.config logger set-pattern "%(asctime)s %(levelname)s %(name)s %(message)s"Shared code for pluginsIf yourplugincontains shared code over allpypesyou can simply put it into a subpackage of yourpluginor into a file prefixed with__, e.g.,__commons__.py.pype-cliwill only scan / consider top-level Python scripts without underscores aspypes.Example recipesYou can register a sampleplugincalledbasicsthat contains some useful recipes to get you started with your own pipes.Register thebasicsplugin:pype pype.config plugin-register --name basics --path <PYPE_REPOSITORY>/example_pypesNavigate topype basics <TAB>to see its contentOpen a recipe in your edior, for example:pype basics --open-pype hello-world-optFor some basic information you can also refer to the built-intemplate.pyandtemplate_minimal.pythat are used on creation of newpypes.Note that as long as you don't import some of theconvenience utilitiesofpype-clidirectly, yourpypewill remainan independent Python scriptthat can be used regardless ofpype_cli.Best practisespype-clihas been built around theClick-project ("Command Line Interface Creation Kit")which is a Python package for creating beautiful command line interfaces. To fully utilize the capabilities ofpype-cliit is highly recommended to get familiar with the project and use it in yourpypesas well. Again you can refer to thebasicsplugin for guidance.pype-cli developmentRunmake venvto create a new virtual environmentRunpipenv shellto activate a local shell with the required configurationsRunpypeto operate locale development version (it will react to code changes)RunPYPE_BENCHMARK_INIT=1 pypeto print loading times for individual plugins or pypesHow to releaseSwitch to latestmainbranch after making sureit is stableGet latest changelog viamake changelogand updateCHANGELOG.mdRunNEXT_VERSION=0.0.3 make releaseTriggerGithub actionto release to PyPiLicense and attributionThis software is licensed underApache License 2.0.Icon made byFreepikfromFlaticonis licensed byCC 3.0 BY.