This release is a pre-release and may not be stable for production use.
Context Cli
Context Cli is a cli tool to search with contexts.
Installation
$ pip install context-cli
Usage
Help
$ ctx -h
usage: ctx [-h] [-t TYPE] [-w] [-d DELIMITER_MATCHER]
[-D DELIMITER_MATCHER] [-s START_DELIMITER_MATCHER]
[-S START_DELIMITER_MATCHER] [-e END_DELIMITER_MATCHER]
[-E END_DELIMITER_MATCHER] [-x] [-X] [-i]
[-c CONTAINS_TEXT] [-C CONTAINS_REGEX] [-m MATCHES_TEXT]
[-M MATCHES_REGEX] [-c! NOT_CONTAINS_TEXT]
[-C! NOT_CONTAINS_REGEX] [-m! NOT_MATCHES_TEXT]
[-M! NOT_MATCHES_REGEX] [-l LINE_CONTAINS_TEXT]
[-L LINE_CONTAINS_REGEX] [-l! NOT_LINE_CONTAINS_TEXT]
[-L! NOT_LINE_CONTAINS_REGEX] [-o OUTPUT_DELIMITER]
[files [files ...]]
A cli tool to search with contexts.
positional arguments:
files
optional arguments:
-h, --help show this help message and exit
-t TYPE, --type TYPE type of search as specified in .ctxrc
-w, --write write the current context search to .ctxrc
-d DELIMITER_MATCHER, --delimiter-text DELIMITER_MATCHER
delimiter text
-D DELIMITER_MATCHER, --delimiter-regex DELIMITER_MATCHER
delimiter regex
-s START_DELIMITER_MATCHER, --delimiter-start-text START_DELIMITER_MATCHER
delimiter start text
-S START_DELIMITER_MATCHER, --delimiter-start-regex START_DELIMITER_MATCHER
delimiter start regex
-e END_DELIMITER_MATCHER, --delimiter-end-text END_DELIMITER_MATCHER
delimiter end text
-E END_DELIMITER_MATCHER, --delimiter-end-regex END_DELIMITER_MATCHER
delimiter end regex
-x, --exclude-start-delimiter
exclude start delimiter from the context
-X, --exclude-end-delimiter
exclude end delimiter from the context
-i, --ignore-end-delimiter
prevent end delimiter from being considered as a start
delimiter (only applies if -X is used)
-c CONTAINS_TEXT, --contains-text CONTAINS_TEXT
display only contexts that have line(s) that contain
this text
-C CONTAINS_REGEX, --contains-regex CONTAINS_REGEX
display only contexts that have line(s) that contain
this regex
-m MATCHES_TEXT, --matches-text MATCHES_TEXT
display only contexts that have line(s) that exactly
match this text
-M MATCHES_REGEX, --matches-regex MATCHES_REGEX
display only contexts that have line(s) that exactly
match this regex
-c! NOT_CONTAINS_TEXT, --not-contains-text NOT_CONTAINS_TEXT
display only contexts that have line(s) that don't
contain this text
-C! NOT_CONTAINS_REGEX, --not-contains-regex NOT_CONTAINS_REGEX
display only contexts that have line(s) that don't
contain this regex
-m! NOT_MATCHES_TEXT, --not-matches-text NOT_MATCHES_TEXT
display only contexts that have line(s) that don't
exactly match this text
-M! NOT_MATCHES_REGEX, --not-matches-regex NOT_MATCHES_REGEX
display only contexts that have line(s) that don't
exactly match this regex
-l LINE_CONTAINS_TEXT, --line-contains-text LINE_CONTAINS_TEXT
display only lines in the context that contain this
text
-L LINE_CONTAINS_REGEX, --line-contains-regex LINE_CONTAINS_REGEX
display only lines in the context that contain this
regex
-l! NOT_LINE_CONTAINS_TEXT, --not-line-contains-text NOT_LINE_CONTAINS_TEXT
display only lines in the context that don't contain
this text
-L! NOT_LINE_CONTAINS_REGEX, --not-line-contains-regex NOT_LINE_CONTAINS_REGEX
display only lines in the context that don't contain
this regex
-o OUTPUT_DELIMITER, --output-delimiter OUTPUT_DELIMITER
Output delimiter
Examples
Extracting code blocks from Markdown
$ ctx -xXi -S '^```$' -E '^```$' -o "========" README.md
This command excludes the start and ending tick blocks from the output. We need the -i to avoid the ticks that cose the code-block from being interpreted as the opening ticks.
The -o adds the "========" between each context.
Filter the output
Only display contexts that have "install"
$ ctx -xXi -S '^```$' -E '^```$' -c install -o "========" README.md
Save common arguments
If you use ctx with the same arguments over and over again, you can save those arguments under a name. In
the following example, we add my_saved_search by using the --type (or -t) and --write (or -w).
$ ctx --type my_saved_search -write -xXi -s '-----' -e 'end' -o '=========='
And then use it (note there is no --write anymore)
$ ctx -t my_saved_search my_file.txt
The configuration is saved to your home folder in a .ctxrc file.
TODO: Add more examples
Metadata
Release files for context-cli 0.0.dev4
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 | |
|---|---|---|---|---|
| context-cli-0.0.dev4.tar.gz | 15.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| context_cli-0.0.dev4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.3 kB
Release files / context-cli-0.0.dev4.tar.gz
| Download URL | context-cli-0.0.dev4.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0178909b499ff00d10e508e3e12925f6732eba10e80ac1d731cc4d1441331c8d
|
|
BLAKE2b-256 checksum How to use checksums |
e06313f552c40651052b4c5eee099b4a18f3ff644b9ed8dc09c8767c22d864a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7
|
Release files / context_cli-0.0.dev4-py3-none-any.whl
| Download URL | context_cli-0.0.dev4-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34b35fec1776131f13eb162d61a7eb90c6c0389e070859e132c8d40cab2ad30d
|
|
BLAKE2b-256 checksum How to use checksums |
b33ca79a8ae76ebf648e4810b8c465ab07f46a19aa39d931f82635851819b4bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7
|
Security for context-cli 0.0.dev4
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.