pyqwe


Namepyqwe JSON
Version 2.1.1 PyPI version JSON
download
home_pageNone
SummaryRun commands quickly from the pyproject.toml (or pyqwe.toml) file.
upload_time2024-11-25 08:27:25
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🏎️💨 pyqwe

The Quick Work Environment for Python.

[![PyPI version](https://img.shields.io/pypi/v/pyqwe)](https://pypi.org/project/pyqwe/)
[![License](https://img.shields.io/github/license/CheeseCake87/pyqwe)](https://raw.githubusercontent.com/CheeseCake87/pyqwe/main/LICENSE)
![Downloads](https://static.pepy.tech/badge/pyqwe)
![black](https://img.shields.io/badge/code%20style-black-000000.svg)

Run commands quickly from the pyproject.toml (or pyqwe.toml) file.

```bash
pip install pyqwe
```
---

<!-- TOC -->
* [🏎️💨 pyqwe](#-pyqwe)
  * [Python commands](#python-commands)
    * [Package example](#package-example)
    * [Module example](#module-example)
  * [*:... commands (terminal)](#-commands-terminal)
    * [Run as shell](#run-as-shell)
    * [Change the working directory](#change-the-working-directory)
  * [Grouped commands](#grouped-commands)
  * [Using environment variables](#using-environment-variables)
  * [Other commands](#other-commands)
<!-- TOC -->

---

**_-- New in 2.1.x ↓_**

Advanced environment variable functionality [Using environment variables](#using-environment-variables).

[See all releases](https://github.com/CheeseCake87/pyqwe/releases)

---

## Usage

Add commands to the pyproject.toml or pyqwe.toml file.

```toml
[tool.pyqwe]
flask = "flask_app:run"
say_hello = "*:echo Hello World"
```

**If you're using a pyqwe.toml file you can drop the `[tool.pyqwe]`**

```toml
flask = "flask_app:run"
say_hello = "*:echo Hello World"
```

🚨 **NOTE** 🚨

**If you have both a pyproject.toml and a pyqwe.toml file, the pyqwe.toml
file will be used and the pyproject.toml file will be ignored.**

You will be able to see what commands you have set in the pyproject.toml file by running:

```bash
pyqwe list
# or
pyqwe ls
```

You can run the commands by using the command name:

```bash
pyqwe flask
```

Running `pyqwe` without any option or command will show all available commands in a menu you can choose from.

```bash
pyqwe
```

```text
🚥|🏎️
0 : Exit
1 : flask
2 : say_hello
Select a command to run [0]:
```

Choosing `1` will run the `flask` command.

## Python commands

For Python, the commands are structured like (package &/ module):function

### Package example

```text
project/
    flask_app/
        __init__.py
```

```toml
[tool.pyqwe]
flask = "flask_app:run"
```

This command will run the function
`run()` from the `__init__.py` file in the `flask_app` package.

### Module example

```text
project/
    app.py
```

```toml
[tool.pyqwe]
flask = "app:run"
```

This command will run the function
`run()` from the `app.py` file.

Now run the pyqwe command:

```bash
pyqwe flask
```

This will start the Flask app.

## *:... commands (terminal)

Any command that starts with `*` will be run using subprocess.

For example:

```toml
[tool.pyqwe]
say_hello = "*:echo Hello World"
```

Now running the pyqwe command:

```bash
pyqwe say_hello
```

Will print `Hello World`.

### Run as shell

To run the command as a subprocess shell command, add the `shell` key to the command.

```toml
[tool.pyqwe]
say_hello = "*shell:echo Hello World"
```

### Change the working directory

You can change the working directory of a subprocess by adding the folder
within parentheses to the command, `(node_app)` for example.

**The folder must be relative** to the pyproject.toml file.

**Absolute paths are not supported**.

**Moving up directories is not supported**, `../node_app` for example.

```toml
[tool.pyqwe]
npm_install = "*(node_app):npm install"
```

The `shell` key is still available when changing the directory.

```toml
[tool.pyqwe]
npm_install = "*shell(node_app):npm i"
```

## Grouped commands

You can group commands together in a list to have one pyqwe command run multiple commands.

Grouped commands can also be run in Step, Sync, or Async mode. Async being the default.

This will run the commands in the group in sequence, pausing for confirmation between each command:

```toml
[tool.pyqwe]
group = [
    "@step",
    "*:echo 'Hello, World! 1'",
    "*:echo 'Hello, World! 2'",
    "*:echo 'Hello, World! 3'"
]
```

This will run the commands in the group in sequence, one after the other:

```toml
[tool.pyqwe]
group = [
    "@sync",
    "*:echo 'Hello, World! 1'",
    "*:echo 'Hello, World! 2'",
    "*:echo 'Hello, World! 3'"
]
```

This will run the commands in the group in parallel:

```toml
[tool.pyqwe]
group = [
    "@async",
    "*:echo 'Hello, World! 1'",
    "*:echo 'Hello, World! 2'",
    "*:echo 'Hello, World! 3'"
]
```

Of course, you can leave out the `@step`, `@sync` or `@async` to use the default async mode.

For example, this will also run the commands in the group in parallel:

```toml
[tool.pyqwe]
group = [
    "*:echo 'Hello, World! 1'",
    "*:echo 'Hello, World! 2'",
    "*:echo 'Hello, World! 3'"
]
```

## Using environment variables

To use environment variables in the command, use the `{{ }}`
markers, these markers are the default but can be changed.

pyqwe will evaluate any environment variables that are set before running any commands.

If pyqwe detects an environment variable that is not set, it will raise an error. An error will
also be raised if environment variables are detected, and you do not have `python-dotenv` installed.

Here's an example of setting an environment variable in a command:

```toml
[tool.pyqwe]
talk = "*shell:echo {{MESSAGE}}"
```

You can change the environment variable markers by changing the `__env_marker_start__` and `__env_marker_end__` settings
keys.

```toml
[tool.pyqwe]
__env_marker_start__ = "*"
__env_marker_end__ = "*"
talk = "*shell:echo *MESSAGE*"
```

pyqwe uses `load_dotenv()` from `python-dotenv` to load the `.env` file. You can change the name of the file to load, or
add multiple env files by setting the `__env_files__` settings key.

```toml
[tool.pyqwe]
__env_files__ = [".env", ".env.local"]
talk = "*shell:echo *MESSAGE*"
```

This is the same as running `load_dotenv(".env")` and `load_dotenv(".env.local")`.

If you want to disable pyqwe from doing anything with environment variables, you can set the `__env_ignore__` settings
key to `true`.

```toml
[tool.pyqwe]
__env_ignore__ = true
talk = "*shell:echo {{MESSAGE}}"
```

This will disable the environment variable evaluation and loading of the `.env` file, and result in `{{MESSAGE}}` being
printed to the console in this case.

## Other commands

`pyqwe` `-h` or `--help` will display help information.

`pyqwe` `--version` or `-v` will display the version of pyqwe.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyqwe",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "David Carmichael <david@uilix.com>",
    "download_url": "https://files.pythonhosted.org/packages/c8/77/47a2487feea53560da16368a37acc81a654548066fa91c66383fb740546b/pyqwe-2.1.1.tar.gz",
    "platform": null,
    "description": "# \ud83c\udfce\ufe0f\ud83d\udca8 pyqwe\n\nThe Quick Work Environment for Python.\n\n[![PyPI version](https://img.shields.io/pypi/v/pyqwe)](https://pypi.org/project/pyqwe/)\n[![License](https://img.shields.io/github/license/CheeseCake87/pyqwe)](https://raw.githubusercontent.com/CheeseCake87/pyqwe/main/LICENSE)\n![Downloads](https://static.pepy.tech/badge/pyqwe)\n![black](https://img.shields.io/badge/code%20style-black-000000.svg)\n\nRun commands quickly from the pyproject.toml (or pyqwe.toml) file.\n\n```bash\npip install pyqwe\n```\n---\n\n<!-- TOC -->\n* [\ud83c\udfce\ufe0f\ud83d\udca8 pyqwe](#-pyqwe)\n  * [Python commands](#python-commands)\n    * [Package example](#package-example)\n    * [Module example](#module-example)\n  * [*:... commands (terminal)](#-commands-terminal)\n    * [Run as shell](#run-as-shell)\n    * [Change the working directory](#change-the-working-directory)\n  * [Grouped commands](#grouped-commands)\n  * [Using environment variables](#using-environment-variables)\n  * [Other commands](#other-commands)\n<!-- TOC -->\n\n---\n\n**_-- New in 2.1.x \u2193_**\n\nAdvanced environment variable functionality [Using environment variables](#using-environment-variables).\n\n[See all releases](https://github.com/CheeseCake87/pyqwe/releases)\n\n---\n\n## Usage\n\nAdd commands to the pyproject.toml or pyqwe.toml file.\n\n```toml\n[tool.pyqwe]\nflask = \"flask_app:run\"\nsay_hello = \"*:echo Hello World\"\n```\n\n**If you're using a pyqwe.toml file you can drop the `[tool.pyqwe]`**\n\n```toml\nflask = \"flask_app:run\"\nsay_hello = \"*:echo Hello World\"\n```\n\n\ud83d\udea8 **NOTE** \ud83d\udea8\n\n**If you have both a pyproject.toml and a pyqwe.toml file, the pyqwe.toml\nfile will be used and the pyproject.toml file will be ignored.**\n\nYou will be able to see what commands you have set in the pyproject.toml file by running:\n\n```bash\npyqwe list\n# or\npyqwe ls\n```\n\nYou can run the commands by using the command name:\n\n```bash\npyqwe flask\n```\n\nRunning `pyqwe` without any option or command will show all available commands in a menu you can choose from.\n\n```bash\npyqwe\n```\n\n```text\n\ud83d\udea5|\ud83c\udfce\ufe0f\n0 : Exit\n1 : flask\n2 : say_hello\nSelect a command to run [0]:\n```\n\nChoosing `1` will run the `flask` command.\n\n## Python commands\n\nFor Python, the commands are structured like (package &/ module):function\n\n### Package example\n\n```text\nproject/\n    flask_app/\n        __init__.py\n```\n\n```toml\n[tool.pyqwe]\nflask = \"flask_app:run\"\n```\n\nThis command will run the function\n`run()` from the `__init__.py` file in the `flask_app` package.\n\n### Module example\n\n```text\nproject/\n    app.py\n```\n\n```toml\n[tool.pyqwe]\nflask = \"app:run\"\n```\n\nThis command will run the function\n`run()` from the `app.py` file.\n\nNow run the pyqwe command:\n\n```bash\npyqwe flask\n```\n\nThis will start the Flask app.\n\n## *:... commands (terminal)\n\nAny command that starts with `*` will be run using subprocess.\n\nFor example:\n\n```toml\n[tool.pyqwe]\nsay_hello = \"*:echo Hello World\"\n```\n\nNow running the pyqwe command:\n\n```bash\npyqwe say_hello\n```\n\nWill print `Hello World`.\n\n### Run as shell\n\nTo run the command as a subprocess shell command, add the `shell` key to the command.\n\n```toml\n[tool.pyqwe]\nsay_hello = \"*shell:echo Hello World\"\n```\n\n### Change the working directory\n\nYou can change the working directory of a subprocess by adding the folder\nwithin parentheses to the command, `(node_app)` for example.\n\n**The folder must be relative** to the pyproject.toml file.\n\n**Absolute paths are not supported**.\n\n**Moving up directories is not supported**, `../node_app` for example.\n\n```toml\n[tool.pyqwe]\nnpm_install = \"*(node_app):npm install\"\n```\n\nThe `shell` key is still available when changing the directory.\n\n```toml\n[tool.pyqwe]\nnpm_install = \"*shell(node_app):npm i\"\n```\n\n## Grouped commands\n\nYou can group commands together in a list to have one pyqwe command run multiple commands.\n\nGrouped commands can also be run in Step, Sync, or Async mode. Async being the default.\n\nThis will run the commands in the group in sequence, pausing for confirmation between each command:\n\n```toml\n[tool.pyqwe]\ngroup = [\n    \"@step\",\n    \"*:echo 'Hello, World! 1'\",\n    \"*:echo 'Hello, World! 2'\",\n    \"*:echo 'Hello, World! 3'\"\n]\n```\n\nThis will run the commands in the group in sequence, one after the other:\n\n```toml\n[tool.pyqwe]\ngroup = [\n    \"@sync\",\n    \"*:echo 'Hello, World! 1'\",\n    \"*:echo 'Hello, World! 2'\",\n    \"*:echo 'Hello, World! 3'\"\n]\n```\n\nThis will run the commands in the group in parallel:\n\n```toml\n[tool.pyqwe]\ngroup = [\n    \"@async\",\n    \"*:echo 'Hello, World! 1'\",\n    \"*:echo 'Hello, World! 2'\",\n    \"*:echo 'Hello, World! 3'\"\n]\n```\n\nOf course, you can leave out the `@step`, `@sync` or `@async` to use the default async mode.\n\nFor example, this will also run the commands in the group in parallel:\n\n```toml\n[tool.pyqwe]\ngroup = [\n    \"*:echo 'Hello, World! 1'\",\n    \"*:echo 'Hello, World! 2'\",\n    \"*:echo 'Hello, World! 3'\"\n]\n```\n\n## Using environment variables\n\nTo use environment variables in the command, use the `{{ }}`\nmarkers, these markers are the default but can be changed.\n\npyqwe will evaluate any environment variables that are set before running any commands.\n\nIf pyqwe detects an environment variable that is not set, it will raise an error. An error will\nalso be raised if environment variables are detected, and you do not have `python-dotenv` installed.\n\nHere's an example of setting an environment variable in a command:\n\n```toml\n[tool.pyqwe]\ntalk = \"*shell:echo {{MESSAGE}}\"\n```\n\nYou can change the environment variable markers by changing the `__env_marker_start__` and `__env_marker_end__` settings\nkeys.\n\n```toml\n[tool.pyqwe]\n__env_marker_start__ = \"*\"\n__env_marker_end__ = \"*\"\ntalk = \"*shell:echo *MESSAGE*\"\n```\n\npyqwe uses `load_dotenv()` from `python-dotenv` to load the `.env` file. You can change the name of the file to load, or\nadd multiple env files by setting the `__env_files__` settings key.\n\n```toml\n[tool.pyqwe]\n__env_files__ = [\".env\", \".env.local\"]\ntalk = \"*shell:echo *MESSAGE*\"\n```\n\nThis is the same as running `load_dotenv(\".env\")` and `load_dotenv(\".env.local\")`.\n\nIf you want to disable pyqwe from doing anything with environment variables, you can set the `__env_ignore__` settings\nkey to `true`.\n\n```toml\n[tool.pyqwe]\n__env_ignore__ = true\ntalk = \"*shell:echo {{MESSAGE}}\"\n```\n\nThis will disable the environment variable evaluation and loading of the `.env` file, and result in `{{MESSAGE}}` being\nprinted to the console in this case.\n\n## Other commands\n\n`pyqwe` `-h` or `--help` will display help information.\n\n`pyqwe` `--version` or `-v` will display the version of pyqwe.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Run commands quickly from the pyproject.toml (or pyqwe.toml) file.",
    "version": "2.1.1",
    "project_urls": {
        "Source": "https://github.com/CheeseCake87/pyqwe"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "985ea62558c8a6de043283c3c93a6bc4d9206a75775669de36ea97dd4093e879",
                "md5": "64f8f26a4c9546af090f3f44eaf915d1",
                "sha256": "7985646b4b3e684943ed65dfe04271642231d9791ab06615bcc43b0fe30356cd"
            },
            "downloads": -1,
            "filename": "pyqwe-2.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "64f8f26a4c9546af090f3f44eaf915d1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 11151,
            "upload_time": "2024-11-25T08:27:24",
            "upload_time_iso_8601": "2024-11-25T08:27:24.508158Z",
            "url": "https://files.pythonhosted.org/packages/98/5e/a62558c8a6de043283c3c93a6bc4d9206a75775669de36ea97dd4093e879/pyqwe-2.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c87747a2487feea53560da16368a37acc81a654548066fa91c66383fb740546b",
                "md5": "61e363a87af40d033113cabbf5fb34f4",
                "sha256": "f595bcf6fe78c05cacd33fa51394707fb49710d2637df032532ee290f67f65f1"
            },
            "downloads": -1,
            "filename": "pyqwe-2.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "61e363a87af40d033113cabbf5fb34f4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 12783,
            "upload_time": "2024-11-25T08:27:25",
            "upload_time_iso_8601": "2024-11-25T08:27:25.489056Z",
            "url": "https://files.pythonhosted.org/packages/c8/77/47a2487feea53560da16368a37acc81a654548066fa91c66383fb740546b/pyqwe-2.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-25 08:27:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CheeseCake87",
    "github_project": "pyqwe",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyqwe"
}
        
Elapsed time: 0.38709s