A simple CLI wrapper
Project description
PyMake
Installing PyMake:
pip install PythonMake
What this program is about:
PyMake is a wrapper that allows you to run multiple commands/scripts with variables that can be provided through CLI.
To run PyMake, you will need to create a PyMake.yaml
file and define a make target recipe. The general structure of
a PyMake.yaml
is:
target:
var:
basic: [var1, var2, var3]
option: {opt1: flag1, opt2:flag2, opt3:flag3}
sequence: [list1, list2]
env: {ENV1: "value1", ENV2: "value2"}
cmd:
- command1
- command2
var
element defines all variables in the namespace local to target
. The variables
can be used to interpolate environment variables or command referencing them via the syntax $(var)
.
basic
variables are variables that take exactly one value. basic
variables can take on default (single) values. A
null
value means that the variables must be defined at run time. basic
variables can be parsed as positional arguments
or by using keyword argument: --<varname> value
.
option
variables take no value but is used to activate the corresponding
option in cmd
. The default value provided for each option
variable specifies how the corresponding option will be
raised in cmd
. If an option
variable is not set at pymake run
, it will not be triggered in the referencing commands.
option
variables can be activated using --<varname>
.
sequence
variables are variables that take on at least one value. sequence
variables can also take on default values,
and a null
default value means that the variable must be provided at pymake run
. sequence
variable can only be defined
using --<varname> value1 value2 ...
.
env
element defines all environment variables. Environment variables will be defined in the shell used to execute the commands.
Environment variables can be set using key: value
pairs, where value is a hard-coded value, or is a reference to a var
variable in this format: key: $(var)
. Note that a reference is not restricted to a single variable. The following definition
is valid:
env:
url: "http://$(hostname):$(port)"
To run a target:
pymake run <target> <arguments>
Quick start:
A Hello World
example:
# PyMake.yaml
hello:
cmd:
- echo "Hello World"
The make file defines the target hello
. Executing hello
requires running the command echo "Hello World"
pymake run hello
Add and Commit example
commit:
var:
basic:
message: null
option:
interactive: "-i"
verbose: "-v"
dryrun: "--dry-run"
sequence:
pathspec: .
cmd:
- git add -A $(verbose) $(interactive) $(pathspec)
- git commit $(verbose) $(dryrun) --message "$(message)"
Acknowledging that you can do pretty much the same thing with every IDE, I just want to show how PyMake can simplify this add to commit git workflow. Note that here you have to add in the quotation marks yourself.
To add a specific file:
pymake run commit "feat: add a new target in PyMake.yaml" --pathspec PyMake.yaml
To add all files
pymake run commit "feat: update current repository"
To do a dryrun
This checks which files are to be committed but does not actually commit.
pymake run commit "feat: do a dry run" --dryrun
Push upstream
push_remote:
var:
basic:
name: feat-dev
main: main
cmd:
- git checkout -B $(name)
- git push -u origin $(name)
- git checkout $(main)
- git branch -d $(name)
If you set your main branch to be protected, the general workflow of going on the website, creating a new branch, checking out to the branch can be a bit mundane. Additionally, you might have accidentally updated your local main, which means you now need to do all the crazy stashing and popping that are too much to remember, try the procedure described here. This will checkout locally to a new branch, create a remote branch with a matching name, then checkout to main and delete the new branch. Now you just need to create a PR on the website and forget all the mundane git stuffs.
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 pythonmake-0.0.16.tar.gz
.
File metadata
- Download URL: pythonmake-0.0.16.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/5.15.0-83-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16b964086c6f7dbf7e476cda4f49972cbda96d70667b9fd8ac0a78eba8edfd03 |
|
MD5 | debd7d929af5ab9411f75f94f6100ab9 |
|
BLAKE2b-256 | 217877d2635b0c78f9cd6bd72e34798feae0841934209580e975d64a971eb59a |
File details
Details for the file pythonmake-0.0.16-py3-none-any.whl
.
File metadata
- Download URL: pythonmake-0.0.16-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/5.15.0-83-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0649db7b8e1207766349d04a5e4342a912add1a692612eec06634cc1bb2157df |
|
MD5 | 4de69a8241b0a9a4b615c0e071db01b5 |
|
BLAKE2b-256 | e5406a695bea4d5250437eb3318f4697b8902ff9709990b6dde89ac8a3c44459 |