Compare commits

..

2 Commits

Author SHA1 Message Date
976502504d Add TODO.md 2022-11-15 18:54:04 +01:00
bbe005e243 Add metavar 2022-11-15 18:47:35 +01:00
5 changed files with 8 additions and 5 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,4 @@
venv/ venv/
*.egg-info/ *.egg-info/
__pycache__/ __pycache__/
*.test_*.srt
dist/ dist/

View File

@@ -9,7 +9,7 @@ python3.9 -m pip install subprompt
## Usage ## Usage
``` ```
usage: subprompt.py [-h] (-d | -r R) [-n N] REGEX FILES [FILES ...] usage: subprompt [-h] (-d | -r SUB) [-n N] REGEX FILES [FILES ...]
Modifies lines matched by a regex interactively Modifies lines matched by a regex interactively
@@ -20,6 +20,6 @@ positional arguments:
optional arguments: optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-d delete line -d delete line
-r R replace match with expression -r SUB replace match with expression
-n N size of lines preview (default=3) -n N size of lines preview (default=3)
``` ```

4
TODO.md Normal file
View File

@@ -0,0 +1,4 @@
- Refactor code, break into functions and clean everything
- Add unit tests
- Improve efficiency
- (maybe?) Add append and prepend flags (already possible with sub expr, so maybe not needed)

View File

@@ -1,6 +1,6 @@
[metadata] [metadata]
name = subprompt name = subprompt
version = 0.0.7 version = 0.0.9
author = Augusto Lenz Gunsch author = Augusto Lenz Gunsch
author_email = augusto@augustogunsch.com author_email = augusto@augustogunsch.com
description = Substitute Regex in files with prompt confirmation description = Substitute Regex in files with prompt confirmation

View File

@@ -166,7 +166,7 @@ def run(args):
parser.add_argument('regex', metavar='REGEX', type=str) parser.add_argument('regex', metavar='REGEX', type=str)
action = parser.add_mutually_exclusive_group(required=True) action = parser.add_mutually_exclusive_group(required=True)
action.add_argument('-d', help='delete line', action='store_true') action.add_argument('-d', help='delete line', action='store_true')
action.add_argument('-r', help='replace match with expression', type=str) action.add_argument('-r', help='replace match with expression', type=str, metavar='SUB')
parser.add_argument('files', metavar='FILES', nargs='+', type=str) parser.add_argument('files', metavar='FILES', nargs='+', type=str)
parser.add_argument('-n', help='size of lines preview (default=3)', type=int, default=3) parser.add_argument('-n', help='size of lines preview (default=3)', type=int, default=3)