commandex v1.0.0

A cross-platform library for creation, storage, management of commands and command packages

Execution of commands, parsing of files with command packages. 100% test coverage.

Python Command Manager Cross-Platform CLI PyPI 100% Coverage

commandex — a cross-platform library for creation, storage, management of commands and command packages. Execution of commands, parsing of files with command packages.

Used to create utilities for working with commands (execution, launch, autorun, storage). You can keep your commands in simple and understandable files, collect them in one place, split into named categories (packages) and execute at any time.

Supported platforms: Windows, Linux, macOS, Termux.

  • Pack — storing commands
  • Command Executors — command execution
  • Pack Makers — create a list with objects of command packages
  • Parsers — parsers for files with command packages
  • Filters — filtering commands
  • Factories — fabric for creating objects
  • Cross-Platform — Windows, Linux, macOS, Termux
  • 100% Test Coverage — fully tested

  1. Create a file with any name, with the extension *.cfg
  2. Use # as a comment, line break for convenience or separation
  3. Use [package name] to specify the name of the command package
  4. After the name, write the commands one per line
  5. To create the next batch, repeat steps 2-4
  6. Between commands, you can insert blank lines or comments

commands.cfg:

# Comments

[package name 1]
command 1
command 2
command N

[package name 2]
command 1
command 2
command N

pip install commandex

Available tools: Pack, Command Executors, Pack Makers, Parsers, Filters, Factories.

from commandex import Commander

commander = Commander()
# Reading command packages from a file.
pack_dict = commander.parsers.cfg_parser.parse('file.cfg')
# Filter packages if needed.
packs = commander.filters.pack_filter.filter_pack_dict(pack_dict, add_list=[], exc_list=[])
# We create a list of package objects for future use.
pack_list = commander.makers.pack_maker.make_pack_list(packs)

# We execute commands from each package.
for pack in pack_list:
    print(pack.name)
    for command in pack.commands:
        print(command)
        commander.executors.os.execute(command)

100% test coverage — All components thoroughly tested.

Run tests:

pip install pytest
pytest -v

Coverage report:

pip install pytest-cov
pytest --cov
pytest --cov --cov-report=html

By using this software, you agree to the full disclaimer terms.

Software provided "AS IS" without warranty. You assume all risks.

Full legal disclaimer: See DISCLAIMER.md

License: BSD 3-Clause License