Name | xontrib-commands JSON |
Version |
0.4.4
JSON |
| download |
home_page | |
Summary | Useful xonsh-shell commands/alias functions |
upload_time | 2023-07-31 18:25:58 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | MIT |
keywords |
xontrib
xonsh
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# xontrib-commands
Useful xonsh-shell commands/alias/completer functions
## Installation
To install use pip:
``` bash
xpip install xontrib-commands
# or: xpip install -U git+https://github.com/jnoortheen/xontrib-commands
```
## Usage
``` bash
xontrib load commands
```
## building alias
Use [`xontrib_commands.argerize:Command`](https://github.com/jnoortheen/xontrib-commands/blob/1bf016e08f192478c6322b2a859ae48567372bdb/xontrib_commands/argerize.py#L21)
to build [arger](https://github.com/jnoortheen/arger) dispatcher
for your functions. This will create a nice alias function with auto-completions support.
```py
from xontrib_commands.argerize import Command
@Command.reg
def record_stats(pkg_name=".", path=".local/stats.txt"):
stat = $(scc @(pkg_name))
echo @($(date) + stat) | tee -a @(path)
```
- Directly passing the `Arger` instances is also supported.
```py
from xontrib_commands.argerize import Arger, Command
arger = Arger(prog="tst", description="App Description goes here")
@arger.add_cmd
def create(name: str):
"""Create new test.
:param name: Name of the test
"""
print(locals())
@arger.add_cmd
def remove(*name: str):
"""Remove a test with variadic argument.
:param name: tests to remove
"""
print(locals())
Command.reg(arger)
```
Now a full CLI is ready
```sh
$ record-stats --help
usage: xonsh [-h] [-p PKG_NAME] [-a PATH]
optional arguments:
-h, --help show this help message and exit
-p PKG_NAME, --pkg-name PKG_NAME
-a PATH, --path PATH
```
## Commands
- The following commands are available once the xontrib is loaded.
### 1. reload-mods
```
usage: reload-mods [-h] name
Reload any python module in the current xonsh session.
Helpful during development.
positional arguments:
name Name of the module/package to reload. Giving partial names matches all the nested modules.
optional arguments:
-h, --help show this help message and exit
Examples
-------
$ reload-mods xontrib
- this will reload all modules imported that starts with xontrib name
Notes
-----
Please use
`import module` or `import module as mdl` patterns
Using
`from module import name`
will not reload the name imported
```
### 2. report-key-bindings
```
usage: report-key-bindings [-h]
Show current Prompt-toolkit bindings in a nice table format
optional arguments:
-h, --help show this help message and exit
```
### 3. dev
```
dev - A command to cd into a directory. (Default action)
Usage:
dev [COMMAND] [OPTIONS] [NAME]
Arguments:
[NAME] - name of the folder to cd into. This searches for names under $PROJECT_PATHS or the ones registered with ``dev add``
Options:
--help [SUBCOMMANDS...] - Display this help and exit
Commands:
add - Register the current folder to dev command.
When using this, it will get saved in a file, also that is used during completions.
ls - Show currently registered paths
load-env FILE - Load environment variables from the given file into Xonsh session
Using https://github.com/theskumar/python-dotenv
Run "dev COMMAND --help" for more information on a command.
```
### 4. parallex
```
usage: parallex [-h] [-s] [-n] [-c] [args ...]
Execute multiple subprocess in parallel
positional arguments:
args individual commands need to be quoted and passed as separate arguments
options:
-h, --help
show this help message and exit
-s, --shell
each command should be run with system's commands
-n, --no-order
commands output are interleaved and not ordered
-c, --hide-cmd
do not print the running command
Examples
--------
running linters in parallel
$ parallex "flake8 ." "mypy xonsh"
```
Raw data
{
"_id": null,
"home_page": "",
"name": "xontrib-commands",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "xontrib,xonsh",
"author": "",
"author_email": "Noortheen Raja NJ <jnoortheen@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/31/81/b5731a02a9f5df335a29d1aa2a7368bfa23e4e4f1df18ebfed1999ad1b12/xontrib-commands-0.4.4.tar.gz",
"platform": null,
"description": "# xontrib-commands\n\nUseful xonsh-shell commands/alias/completer functions\n\n## Installation\n\nTo install use pip:\n\n``` bash\nxpip install xontrib-commands\n# or: xpip install -U git+https://github.com/jnoortheen/xontrib-commands\n```\n\n## Usage\n\n``` bash\nxontrib load commands\n```\n\n## building alias\n\nUse [`xontrib_commands.argerize:Command`](https://github.com/jnoortheen/xontrib-commands/blob/1bf016e08f192478c6322b2a859ae48567372bdb/xontrib_commands/argerize.py#L21) \nto build [arger](https://github.com/jnoortheen/arger) dispatcher\nfor your functions. This will create a nice alias function with auto-completions support.\n\n```py\nfrom xontrib_commands.argerize import Command\n\n@Command.reg\ndef record_stats(pkg_name=\".\", path=\".local/stats.txt\"):\n stat = $(scc @(pkg_name))\n echo @($(date) + stat) | tee -a @(path)\n```\n\n- Directly passing the `Arger` instances is also supported. \n\n```py\nfrom xontrib_commands.argerize import Arger, Command\n\narger = Arger(prog=\"tst\", description=\"App Description goes here\")\n\n@arger.add_cmd\ndef create(name: str):\n \"\"\"Create new test.\n\n :param name: Name of the test\n \"\"\"\n print(locals())\n\n@arger.add_cmd\ndef remove(*name: str):\n \"\"\"Remove a test with variadic argument.\n\n :param name: tests to remove\n \"\"\"\n print(locals())\n\nCommand.reg(arger)\n```\n\nNow a full CLI is ready\n```sh\n$ record-stats --help \nusage: xonsh [-h] [-p PKG_NAME] [-a PATH]\n\noptional arguments:\n -h, --help show this help message and exit\n -p PKG_NAME, --pkg-name PKG_NAME\n -a PATH, --path PATH\n```\n\n## Commands\n\n- The following commands are available once the xontrib is loaded.\n\n### 1. reload-mods\n\n```\nusage: reload-mods [-h] name\n\nReload any python module in the current xonsh session.\nHelpful during development.\n\npositional arguments:\n name Name of the module/package to reload. Giving partial names matches all the nested modules.\n\noptional arguments:\n -h, --help show this help message and exit\n\nExamples\n-------\n$ reload-mods xontrib\n - this will reload all modules imported that starts with xontrib name\n\nNotes\n-----\n Please use\n `import module` or `import module as mdl` patterns\n Using\n `from module import name`\n will not reload the name imported\n\n``` \n \n\n### 2. report-key-bindings\n\n```\nusage: report-key-bindings [-h]\n\nShow current Prompt-toolkit bindings in a nice table format\n\noptional arguments:\n -h, --help show this help message and exit\n\n``` \n \n\n### 3. dev\n\n```\ndev - A command to cd into a directory. (Default action)\n\nUsage:\ndev [COMMAND] [OPTIONS] [NAME]\n\nArguments:\n [NAME] - name of the folder to cd into. This searches for names under $PROJECT_PATHS or the ones registered with ``dev add``\n\nOptions:\n --help [SUBCOMMANDS...] - Display this help and exit\n\nCommands:\n add - Register the current folder to dev command.\n When using this, it will get saved in a file, also that is used during completions.\n ls - Show currently registered paths\n load-env FILE - Load environment variables from the given file into Xonsh session\n \n Using https://github.com/theskumar/python-dotenv\n\nRun \"dev COMMAND --help\" for more information on a command.\n\n``` \n\n### 4. parallex\n\n```\nusage: parallex [-h] [-s] [-n] [-c] [args ...]\n\nExecute multiple subprocess in parallel\n\npositional arguments:\n args individual commands need to be quoted and passed as separate arguments\n\noptions:\n -h, --help\n show this help message and exit\n -s, --shell\n each command should be run with system's commands\n -n, --no-order\n commands output are interleaved and not ordered\n -c, --hide-cmd\n do not print the running command\n\nExamples\n--------\nrunning linters in parallel\n $ parallex \"flake8 .\" \"mypy xonsh\"\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Useful xonsh-shell commands/alias functions",
"version": "0.4.4",
"project_urls": {
"Code": "https://github.com/jnoortheen/xontrib-commands",
"Documentation": "https://github.com/jnoortheen/xontrib-commands/blob/master/README.md",
"Issue tracker": "https://github.com/jnoortheen/xontrib-commands/issues",
"repository": "https://github.com/jnoortheen/xontrib-commands"
},
"split_keywords": [
"xontrib",
"xonsh"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bfbf0453ebbf28403b6c960e41892c16b31224fbdde3e2e40fc3e5b84f31a00b",
"md5": "9e1f23bda0edb8af2f80d99eaac142f8",
"sha256": "89294efede07417fb5c827eee63927ea96f462c50c6eb9404dee6175ccbfaae4"
},
"downloads": -1,
"filename": "xontrib_commands-0.4.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9e1f23bda0edb8af2f80d99eaac142f8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 12151,
"upload_time": "2023-07-31T18:25:56",
"upload_time_iso_8601": "2023-07-31T18:25:56.926263Z",
"url": "https://files.pythonhosted.org/packages/bf/bf/0453ebbf28403b6c960e41892c16b31224fbdde3e2e40fc3e5b84f31a00b/xontrib_commands-0.4.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3181b5731a02a9f5df335a29d1aa2a7368bfa23e4e4f1df18ebfed1999ad1b12",
"md5": "51de27ff3b4a833298de9b1ad02ba52f",
"sha256": "c7e077d16936d0fbfff59a8e25c80c9027bff6c5698992c948fff6d884a39394"
},
"downloads": -1,
"filename": "xontrib-commands-0.4.4.tar.gz",
"has_sig": false,
"md5_digest": "51de27ff3b4a833298de9b1ad02ba52f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 10893,
"upload_time": "2023-07-31T18:25:58",
"upload_time_iso_8601": "2023-07-31T18:25:58.256358Z",
"url": "https://files.pythonhosted.org/packages/31/81/b5731a02a9f5df335a29d1aa2a7368bfa23e4e4f1df18ebfed1999ad1b12/xontrib-commands-0.4.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-31 18:25:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jnoortheen",
"github_project": "xontrib-commands",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "xontrib-commands"
}