5 releases (breaking)
| 0.5.0 | Sep 28, 2020 |
|---|---|
| 0.4.0 | Sep 21, 2020 |
| 0.3.0 | Sep 15, 2020 |
| 0.2.0 | Sep 1, 2020 |
| 0.1.0 | Aug 31, 2020 |
#5 in #fashion
76 downloads per month
30KB
637 lines
toggle-comment
toggle-comment is a utility designed around setting or toggling the line-comment status of lines in plain text files in a do-what-I-mean fashion. It aims for muscle-memory compatibility with GNU sed.
Examples
$ cat > example.py <<'EOF'
def greet(name):
# Give salutations
return f'Hello, {name}!'
print(greet('world'))
EOF
$ toggle-comment '/def/,/return/' example.py
# def greet(name):
# # Give salutations
# return f'Hello, {name}!'
print(greet('world'))
$ toggle-comment '1,3' example.py | toggle-comment '4,5!'
def greet(name):
# Give salutations
return f'Hello, {name}!'
print(greet('world'))
Caveats
- Regular expression syntax matches the Rust
regexcrate. Notable differences are in the (lack of) escapes for special characters, e.g./a|b/vs/a\|b/ - Currently unsupported features include:
- in-place editing of files;
- multiple file arguments;
- POSIX sed
M~N"step-wise" patterns, e.g.1~3matching lines 1, 4, 7...; - GNU sed
addr,~N"up-to-multiple", e.g.10,~7matching lines 10-14; and - non-slash regular expression delimeters, e.g.
\|http://|(initial backslash followed by delimiter);
Dependencies
~2.7–4MB
~58K SLoC