Runs multi scripts with a simple line of prompt with a config dot file in your environment
Project description
pyautorun
pyauto is a Python module that acts like a Makefile for Python projects. It allows you to define and execute a set of scripts easily using a configuration file. This tool helps in organizing and automating common project commands.
Features
- Configuration Management: Store and organize scripts in a configuration file.
- Easy Initialization: Quickly create a default configuration file.
- Add Scripts: Append new commands to your configuration.
- Search: Find specific commands within the configuration.
- Execute Scripts: Run entire sections or individual commands by referencing their headers.
Installation
To install pyautorun, use pip:
pip install pyautorun
Configuration File Format
The default configuration file is .pyscripts
, but you can specify a custom config file if needed.
Rules for Configuration File
-
LOC Header: The first line of the configuration file must always contain the Line Of Configuration (LOC) metadata, as follows:
# Line Of Configuration (LOC) file = <filename> [<timestamp>]
- This line will be automatically added during initialization
pyauto init
.
- This line will be automatically added during initialization
-
Headers: Every section must have a header. Headers should:
- Begin with
[py.
and end with]
. - Be properly closed, e.g.,
[py.header]
. - One header can contain multiple commands.
- Begin with
-
Commands: Commands under each header must follow this format:
- Each command should have a name and be assigned using
name = command
. - The first
=
in a line is prioritized to separate the command name from the script.
- Each command should have a name and be assigned using
-
Comments: Comments can be prefixed with
#
and end with a newline. -
Ignored Lines: Any lines that do not follow these rules will be ignored during execution.
Example .pyscripts
File
# Line Of Configuration (LOC) file = .pyscripts [Sun Oct 13 22:44:48 2024]
# comment
[py.header1]
cmd1_h1 = command 1 execution
cmd2_h1 = command 2 execution
[py.help]
help = python --help
python = python --help
Structure
- Each header (e.g.,
[py.header1]
) contains one or more command lines. - Commands are defined using
name = command
pairs, where the name is the command name and the command is the script to execute.
Usage
1. Create a Config File
To initialize a configuration file, use the init
command:
pyauto init <file_name(optional)>
By default, the config file is created as .pyscripts
, but you can provide a custom file name.
2. Add Commands
Add commands to a header within your config file using the add
command:
pyauto add -h <header_name> -s '<script>' -c <configfile(optional)>
-h <header_name>
: Specify the header to add the command to.-s '<script>'
: The script to be added, in the formatname = command
.-c <configfile>
: Optional argument to specify the configuration file (default:.pyscripts
).
3. Find Commands
Search for commands in the config file that start with a specific string:
pyauto find -l <line Startswith> -h <header> -c <configfile(optional)>
-l <line Startswith>
: Specify the line to find.-h <header>
: Specify the header to find.-c <configfile>
: Optional argument to specify the configuration file (default:.pyscripts
).
This will output all lines or header in the file that match the specified prefix.
4. Run Commands
Run all the commands in a specific header or a particular command by referencing it:
- To run all commands in a header:
pyauto run <header>
- To run a specific command within a header:
pyauto run <header>.<command_name>
Example Workflow
-
Initialize the config:
pyauto init .pyautorun.test
-
Add a new command:
pyauto add -h tests -s "test = tested sucessfully" -c .pyautorun.test
-
Run a command from the header:
pyauto run tests -c .pyautorun.test
-
Find commands starting with a specific line:
pyauto find -l test -h tests -c .pyautorun.test
Contributing
If you have any suggestions or feedback, please open an issue or create a pull request.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file autoruncmd-0.1.0.tar.gz
.
File metadata
- Download URL: autoruncmd-0.1.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1008560a3917762fa9668e5de3b9531c68e0ca928f9ddb1cae8f1017fca2c7fe |
|
MD5 | e3e78c571a85c0956a085db6b905b78f |
|
BLAKE2b-256 | 81206860b4dd7a17544b1feb6e65153491f387559955d64a0ee11919dc4be27e |
File details
Details for the file AutoRunCmd-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: AutoRunCmd-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3289ae55b6cbfa4142b32f54579bbfd4fa871acdaf2322cf1dc5449e8aa10a0 |
|
MD5 | da297f8f51a401967f4f2daee9b44fa3 |
|
BLAKE2b-256 | abdae890e59a6aa8c33ccc793afb4c3ed3b10ed47793158f93836336cd5b8a01 |