Skip to main content

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

Project description

commandex


GitHub top language PyPI - Downloads GitHub release (latest by date) GitHub PyPI PyPI - Format GitHub Repo stars GitHub watchers GitHub forks


Short Description:

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


Author and developer: A.A. Suvorov

smartlegiondev@gmail.com


Supported:

  • Linux: All.
  • Windows: 7/8/10.
  • Termux (Android).

What's new?

commandex v0.2.3


Description:

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

  • Store the required commands under a given name in a simple file with a clear structure.
  • Read named command packages from a file.
  • Use only the required command packages from a file using filtering.
  • Execute command packages cross-platform.

How it works?

  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 that you decided to combine under this name, one per line.
  5. To create the next batch of commands, use points 2, 3 again.
  6. Between commands, you can insert blank lines or comments, see point 2.

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:

The files must have the extension *.cfg, and have the correct structure:

commands.cfg:

# Comments

[package name 1]
command 1
command 2
command N

[package name 2]
command 1
command 2
command N

Help:

Install and Use:

  • pip install commandex

Available tools:

  • 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.

Principle of operation:

  • Reading command packages from a file.
  • Filter packages if needed.
  • We create a list of package objects for future use.
  • We execute commands from each package.

Simplest implementation:

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)

Termux, Windows support:

Utilities created with use work "commandex", without problems in Termux, Windows.

For example: commandman.


Test coverage:

Run tests:

  • pip install pytest
  • pytest -v

Test coverage 100%

  • pip install pytest-coverage
  • pytest --cov

commandex image

Report html:

  • pytest --cov --cov-report=html

Disclaimer of liability:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Copyright:

--------------------------------------------------------
Licensed under the terms of the BSD 3-Clause License
(see LICENSE for details).
Copyright © 2018-2024, A.A. Suvorov
All rights reserved.
--------------------------------------------------------
https://github.com/smartlegionlab
--------------------------------------------------------

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

commandex-0.2.3.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

commandex-0.2.3-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file commandex-0.2.3.tar.gz.

File metadata

  • Download URL: commandex-0.2.3.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for commandex-0.2.3.tar.gz
Algorithm Hash digest
SHA256 221a4450db9d649f111250c15965a9507a72b61197f8458a0cb8b7842a677582
MD5 47214760edf1222e9490d7be0e44664b
BLAKE2b-256 b9f78e2be0a419dc10bfa78fdafd5be756668bf37d9123dd5898f83c027716be

See more details on using hashes here.

File details

Details for the file commandex-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: commandex-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for commandex-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cb1a2252f3c9a0faae8c024493e7fbfd10bdb54f46fb188e8c21fa4e36cfaa19
MD5 9541b5bf9020ea2996778dd3ececc060
BLAKE2b-256 6a15d25f8b27c3b6a916d6d7c8062e4466cdfd07d2c6d6b55f1bb033182309d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page