massedit-cli
Python mass editor CLI.
The missing entry point for massedit.
massedit-cli vendors massedit so that you can install it with pipx and use it
no matter which the python virtual env you're in the what which python3 points to.
Installation
pipx
This is the recommended installation method.
$ pipx install massedit-cli
pip
$ pip install massedit-cli
Usage
Check out massedit to learn more.
usage: massedit [-h] [-V] [-w] [-v] [-e EXPRESSIONS] [-f FUNCTIONS] [-x EXECUTABLES] [-s START_DIRS] [-m MAX_DEPTH] [-o FILE] [-g FILE] [--encoding ENCODING]
[--newline NEWLINE]
[file pattern ...]
Python mass editor
positional arguments:
file pattern shell-like file name patterns to process or - to read from stdin.
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-w, --write modify target file(s) in place. Shows diff otherwise.
-v, --verbose increases log verbosity (can be specified multiple times)
-e EXPRESSIONS, --expression EXPRESSIONS
Python expressions applied to target files. Use the line variable to reference the current line.
-f FUNCTIONS, --function FUNCTIONS
Python function to apply to target file. Takes file content as input and yield lines. Specify function as [module]:?<function name>.
-x EXECUTABLES, --executable EXECUTABLES
Python executable to apply to target file.
-s START_DIRS, --start START_DIRS
Directory(ies) from which to look for targets.
-m MAX_DEPTH, --max-depth-level MAX_DEPTH
Maximum depth when walking subdirectories.
-o FILE, --output FILE
redirect output to a file
-g FILE, --generate FILE
generate stub file suitable for -f option
--encoding ENCODING Encoding of input and output files
--newline NEWLINE Newline character for output files
Examples:
# Simple string substitution (-e). Will show a diff. No changes applied.
massedit -e "re.sub('failIf', 'assertFalse', line)" *.py
# File level modifications (-f). Overwrites the files in place (-w).
massedit -w -f fixer:fixit *.py
# Will change all test*.py in subdirectories of tests.
massedit -e "re.sub('failIf', 'assertFalse', line)" -s tests test*.py
# Will transform virtual methods (almost) to MOCK_METHOD suitable for gmock (see https://github.com/google/googletest).
massedit -e "re.sub(r'\s*virtual\s+([\w:<>,\s&*]+)\s+(\w+)(\([^\)]*\))\s*((\w+)*)(=\s*0)?;', 'MOCK_METHOD(\g<1>, \g<2>, \g<3>, (\g<4>, override));', line)" test.cpp
Develop
$ git clone https://github.com/tddschn/massedit-cli.git
$ cd massedit-cli
$ poetry install
Metadata
Release files for massedit-cli 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| massedit-cli-0.1.3.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| massedit_cli-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.0 kB
Release files / massedit-cli-0.1.3.tar.gz
| Download URL | massedit-cli-0.1.3.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2a0ffaef0ae940540cd71412118b35a8f3ede9f5e36505624d252ef5e6ab70b
|
|
BLAKE2b-256 checksum How to use checksums |
2790289c2ca9134d989ddd95073d3a3742e151b862e0da2deb19180ce1e8ea3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.4 Darwin/21.4.0
|
Release files / massedit_cli-0.1.3-py3-none-any.whl
| Download URL | massedit_cli-0.1.3-py3-none-any.whl |
|---|---|
| Size | 2.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7a1945c8cafd8f86fa3ee255f5ffd8e1bfcc271d5799b86336a5a2c7084699a9
|
|
BLAKE2b-256 checksum How to use checksums |
6ba6dd65746f7ec1d053c8a88a10c926a5b7ed49e4bceeb9fe5acb73f78750f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.4 Darwin/21.4.0
|