This is a simple tool to format every line in a text file or stdin.
This is a simple tool to format every line in a text file or stdin.
Install it as a global tool here:
dotnet tool install -g format-lines
If you already have it installed, make sure to update:
dotnet tool update -g format-lines
format-lines [options] format
Arguments:
format Line format where {0} is initial line.
Options:
-i, --input Input file to be processed. If not set stdin will be used.
-d, --delimiter Delimiter for formatted lines. Default value is new line.
-t, --trim If set, the input lines will be trimmed before formatting.
-e, --ignore-empty-lines If set, empty or whitespace lines will not be formatted and included in result.
-m, --min-length Minimum length for lines to be formatted and included in result.
-o, --output Output file name. If not set, stdout will be used.
--version Show version information
-?, -h, --help Show help and usage information
Add single quotes for every line in input.txt and save it to output.txt:
format-lines '{0}' -i input.txt -o output.txt
or:
format-lines '{0}' > output.txt < input.txt
Write lines manually and save them surrounded by simgle quotes to output.txt:
format-lines '{0}' -o output.txt
Note: you can exit this process with Ctrl + C.
Trim all lines, remove every empty line, remove all lines with length less than 2, format to some pseudo json with square brackets ‘[ “value”: “%MyLine%” ]’ every line in input.txt and save it to output.txt in a single line with comma as delimiter:
format-lines "[ ""value"": ""{0}"" ]" --input input.txt --trim --ignore-empty-lines --min-length 2 --delimiter , --output output.txt
There is a lot of overengineering here, and it was supposed to be that way =)