Skip to content

Extra small zero-dependency management commands library for python apps

License

Notifications You must be signed in to change notification settings

python-pkgz/management_commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commands

Extra small zero-dependency management commands library for python apps

Installation

pip3 install management_commands

Example

import os

from management_commands import Command, main


class Ls(Command):
    def add_arguments(self, parser):
        parser.add_argument('-1', action='store_true', dest='onecol')
        parser.add_argument('path')

    def handle(self, onecol, path, **kwargs) -> None:
        sep = ', '

        if onecol:
            sep = '\n'

        print(sep.join(os.listdir(path)))


if __name__ == '__main__':
    main(commands=[Ls()])
$ python3 example.py 
usage: example.py [-h] {ls} ...

$ python3 example.py --help
usage: example.py [-h] {ls} ...

optional arguments:
  -h, --help  show this help message and exit

commands:
  {ls}

$ python3 example.py ls .
LICENSE, dist, Makefile, MANIFEST.in, README.md, commands.egg-info, setup.py, example.py, .gitignore, management_commands, management_commands.egg-info, venv, .git, .idea

$ python3 example.py ls -1 .
LICENSE
dist
Makefile
MANIFEST.in
README.md
commands.egg-info
setup.py
example.py
.gitignore
management_commands
management_commands.egg-info
venv
.git
.idea

About

Extra small zero-dependency management commands library for python apps

Resources

License

Stars

Watchers

Forks

Packages

No packages published