blue-options


Nameblue-options JSON
Version 4.236.1 PyPI version JSON
download
home_pagehttps://github.com/kamangir/blue-options
Summary🌀 options for Bash.
upload_time2025-03-15 04:38:17
maintainerNone
docs_urlNone
authorArash Abadpour (Kamangir)
requires_pythonNone
licensePublic Domain
keywords
VCS
bugtrack_url
requirements blueness matplotlib numpy pymysql pyyaml pylint pytest python-dotenv tqdm
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🌀 blue-options

🌀 `blue_options` implements an `options` argument for Bash.

here is an example use of an `options` in the [vancouver-watching 🌈](https://github.com/kamangir/vancouver-watching) ingest command:


```bash
 > @help vanwatch ingest
```
```bash
vanwatch \
	ingest \
	[area=<area>,count=<-1>,~download,dryrun,~upload] \
	[-|<object-name>] \
	[process,count=<-1>,~download,dryrun,gif,model=<model-id>,publish,~upload] \
	[--detect_objects 0] \
	[--overwrite 1] \
	[--verbose 1]
```

this command takes in an `options`, an `object`, and `args`. an `options` is a string representation of a dictionary, such as,

```bash
area=<vancouver>,~batch,count=<-1>,dryrun,gif,model=<model-id>,~process,publish,~upload
```

which is equivalent, in json notation, to,

```json
{
    "area": "vancouver",
    "batch": false,
    "count": -1,
    "dryrun": true,
    "gif": true,
    "model": "<model-id>",
    "process": false,
    "publish": true,
    "upload": false,
}
```

for more refer to 🔻 [giza](https://github.com/kamangir/giza).

## installation

```bash
pip install blue_options
```

add this line to your `~/.bash_profile` or `~/.bashrc`,

```bash
source $(python3 -m blue_options locate)/.bash/blue_options.sh
```

## usage

let your function receive an `options` argument, then parse it with `abcli_options` and `abcli_options_int`.

```bash
function func() {
    local options=$1

    local var=$(abcli_options "$options" var default)
    local key=$(abcli_options_int "$options" key 0)

    [[ "$key" == 1 ]] &&
        echo "var=$var"
}
```

## example 1

from [reddit](https://www.reddit.com/r/bash/comments/1duw6ac/how_can_i_automate_these_tree_commands_i/)

> How can I automate these tree commands I frequently need to type out?
I would like to run:
```bash
git add .
git commit -m "Initial "commit"
git push
```
> I got bored of typing them out each time. Can I make an alias or something like "gc" (for git commit). The commit message is always the same "Initial commit".

first, install `blue-options`. this will also install [`blueness`](https://github.com/kamangir/blueness).

```bash
pip install blue_options
```

then, copy [`example1.sh`](https://raw.githubusercontent.com/kamangir/blue-options/main/blue_options/assets/example1.sh) to your machine and add this line to the end of your `bash_profile`,

```bash
source <path/to/example1.sh>
```

now, you have access to the `@git` super command. here is how it works.

1. `@git help` shows usage instructions (see below).
1. `@git commit` runs the three commands. you can customize the message by running `@git commit <message>`. you can also avoid the push by running `@git commit <message> ~push`.
1. for any `<task>` other than `commit`, `@git <task> <args>` runs `git <task> <args>`.

```
 > @git help
 @git commit [<message>] \
	~push
 . git commit with <message> and push.
@git <command>
 . git <command>.
 ```

![image](https://raw.githubusercontent.com/kamangir/assets/main/blue-options/example1.png)

---

[![pylint](https://github.com/kamangir/blue-options/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-options/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-options/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-options/actions/workflows/pytest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-options.svg)](https://pypi.org/project/blue-options/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-options)](https://pypistats.org/packages/blue-options)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kamangir/blue-options",
    "name": "blue-options",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Arash Abadpour (Kamangir)",
    "author_email": "arash@kamangir.net",
    "download_url": "https://files.pythonhosted.org/packages/ea/5b/15841b923b7e33b3736c667add8e69fb689b7fb6455166d2c7bb700428c2/blue_options-4.236.1.tar.gz",
    "platform": null,
    "description": "# \ud83c\udf00 blue-options\n\n\ud83c\udf00 `blue_options` implements an `options` argument for Bash.\n\nhere is an example use of an `options` in the [vancouver-watching \ud83c\udf08](https://github.com/kamangir/vancouver-watching) ingest command:\n\n\n```bash\n > @help vanwatch ingest\n```\n```bash\nvanwatch \\\n\tingest \\\n\t[area=<area>,count=<-1>,~download,dryrun,~upload] \\\n\t[-|<object-name>] \\\n\t[process,count=<-1>,~download,dryrun,gif,model=<model-id>,publish,~upload] \\\n\t[--detect_objects 0] \\\n\t[--overwrite 1] \\\n\t[--verbose 1]\n```\n\nthis command takes in an `options`, an `object`, and `args`. an `options` is a string representation of a dictionary, such as,\n\n```bash\narea=<vancouver>,~batch,count=<-1>,dryrun,gif,model=<model-id>,~process,publish,~upload\n```\n\nwhich is equivalent, in json notation, to,\n\n```json\n{\n    \"area\": \"vancouver\",\n    \"batch\": false,\n    \"count\": -1,\n    \"dryrun\": true,\n    \"gif\": true,\n    \"model\": \"<model-id>\",\n    \"process\": false,\n    \"publish\": true,\n    \"upload\": false,\n}\n```\n\nfor more refer to \ud83d\udd3b [giza](https://github.com/kamangir/giza).\n\n## installation\n\n```bash\npip install blue_options\n```\n\nadd this line to your `~/.bash_profile` or `~/.bashrc`,\n\n```bash\nsource $(python3 -m blue_options locate)/.bash/blue_options.sh\n```\n\n## usage\n\nlet your function receive an `options` argument, then parse it with `abcli_options` and `abcli_options_int`.\n\n```bash\nfunction func() {\n    local options=$1\n\n    local var=$(abcli_options \"$options\" var default)\n    local key=$(abcli_options_int \"$options\" key 0)\n\n    [[ \"$key\" == 1 ]] &&\n        echo \"var=$var\"\n}\n```\n\n## example 1\n\nfrom [reddit](https://www.reddit.com/r/bash/comments/1duw6ac/how_can_i_automate_these_tree_commands_i/)\n\n> How can I automate these tree commands I frequently need to type out?\nI would like to run:\n```bash\ngit add .\ngit commit -m \"Initial \"commit\"\ngit push\n```\n> I got bored of typing them out each time. Can I make an alias or something like \"gc\" (for git commit). The commit message is always the same \"Initial commit\".\n\nfirst, install `blue-options`. this will also install [`blueness`](https://github.com/kamangir/blueness).\n\n```bash\npip install blue_options\n```\n\nthen, copy [`example1.sh`](https://raw.githubusercontent.com/kamangir/blue-options/main/blue_options/assets/example1.sh) to your machine and add this line to the end of your `bash_profile`,\n\n```bash\nsource <path/to/example1.sh>\n```\n\nnow, you have access to the `@git` super command. here is how it works.\n\n1. `@git help` shows usage instructions (see below).\n1. `@git commit` runs the three commands. you can customize the message by running `@git commit <message>`. you can also avoid the push by running `@git commit <message> ~push`.\n1. for any `<task>` other than `commit`, `@git <task> <args>` runs `git <task> <args>`.\n\n```\n > @git help\n @git commit [<message>] \\\n\t~push\n . git commit with <message> and push.\n@git <command>\n . git <command>.\n ```\n\n![image](https://raw.githubusercontent.com/kamangir/assets/main/blue-options/example1.png)\n\n---\n\n[![pylint](https://github.com/kamangir/blue-options/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-options/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-options/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-options/actions/workflows/pytest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-options.svg)](https://pypi.org/project/blue-options/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-options)](https://pypistats.org/packages/blue-options)\n",
    "bugtrack_url": null,
    "license": "Public Domain",
    "summary": "\ud83c\udf00 options for Bash.",
    "version": "4.236.1",
    "project_urls": {
        "Homepage": "https://github.com/kamangir/blue-options"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6899b5f285ae1586963f86c5ef0e22f42f3484d873b6270b751ffd1c29aef947",
                "md5": "7b369384143f26180052096ef9d1279b",
                "sha256": "d3e934df729684d2cb84448ad44b37e8c6f18bb9b29d8f67e818025396e30078"
            },
            "downloads": -1,
            "filename": "blue_options-4.236.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7b369384143f26180052096ef9d1279b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 43071,
            "upload_time": "2025-03-15T04:38:16",
            "upload_time_iso_8601": "2025-03-15T04:38:16.183023Z",
            "url": "https://files.pythonhosted.org/packages/68/99/b5f285ae1586963f86c5ef0e22f42f3484d873b6270b751ffd1c29aef947/blue_options-4.236.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ea5b15841b923b7e33b3736c667add8e69fb689b7fb6455166d2c7bb700428c2",
                "md5": "d543d7504a7c4940ad2d1b1496f75658",
                "sha256": "15924519105e3f51e20615bace0b01a9408b4e034ba5f2935440bfa45bd64819"
            },
            "downloads": -1,
            "filename": "blue_options-4.236.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d543d7504a7c4940ad2d1b1496f75658",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 28932,
            "upload_time": "2025-03-15T04:38:17",
            "upload_time_iso_8601": "2025-03-15T04:38:17.298053Z",
            "url": "https://files.pythonhosted.org/packages/ea/5b/15841b923b7e33b3736c667add8e69fb689b7fb6455166d2c7bb700428c2/blue_options-4.236.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-03-15 04:38:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kamangir",
    "github_project": "blue-options",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "blueness",
            "specs": []
        },
        {
            "name": "matplotlib",
            "specs": []
        },
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "pymysql",
            "specs": []
        },
        {
            "name": "pyyaml",
            "specs": []
        },
        {
            "name": "pylint",
            "specs": []
        },
        {
            "name": "pytest",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "tqdm",
            "specs": []
        }
    ],
    "lcname": "blue-options"
}
        
Elapsed time: 1.78389s