xontrib-commands
Useful xonsh-shell commands/alias/completer functions
Installation
To install use pip:
xpip install xontrib-commands
# or: xpip install -U git+https://github.com/jnoortheen/xontrib-commands
Usage
xontrib load commands
building alias
Use xontrib_commands.argerize:Command
to build arger dispatcher
for your functions. This will create a nice alias function with auto-completions support.
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
Argerinstances is also supported.
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
$ 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"
Metadata
Release files for xontrib-commands 0.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xontrib-commands-0.4.4.tar.gz | 10.9 kB | Without provenance | Details for xontrib-commands-0.4.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xontrib_commands-0.4.4-py3-none-any.whl | Python 3 | none | any | Details for xontrib_commands-0.4.4-py3-none-any.whl |
Total release size: 23.0 kB
Release files / xontrib-commands-0.4.4.tar.gz
| Download URL | xontrib-commands-0.4.4.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7e077d16936d0fbfff59a8e25c80c9027bff6c5698992c948fff6d884a39394
|
|
BLAKE2b-256 checksum How to use checksums |
3181b5731a02a9f5df335a29d1aa2a7368bfa23e4e4f1df18ebfed1999ad1b12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.8.2 CPython/3.11.4
|
Release files / xontrib_commands-0.4.4-py3-none-any.whl
| Download URL | xontrib_commands-0.4.4-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89294efede07417fb5c827eee63927ea96f462c50c6eb9404dee6175ccbfaae4
|
|
BLAKE2b-256 checksum How to use checksums |
bfbf0453ebbf28403b6c960e41892c16b31224fbdde3e2e40fc3e5b84f31a00b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.8.2 CPython/3.11.4
|
Security for xontrib-commands 0.4.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.