comby icon indicating copy to clipboard operation
comby copied to clipboard

Matching '--'

Open GarkGarcia opened this issue 5 years ago • 1 comments

Hey, I'm trying to match Haskell line comments, which start with --, but I'm getting the following error:

$ comby "-- " "--- " ./file
Error parsing command line.  Run with -help for usage information.
unknown flag --

Is there a way around it?

GarkGarcia avatar Jan 23 '20 18:01 GarkGarcia

Hey @GarkGarcia

It seems there is some trouble with escaping -- so that comby doesn't think it is a flag. There isn't a way around this directly on the command line and I'll have to investigate.

The good news is that there's an overall workaround, but it is a little roundabout. You can create templates in files and the contents will be read from there and not parsed on the command line using the -templates option. For your example:

mkdir templates
cd templates
touch match
# open the match file and enter the contents `-- `
touch rewrite
# open the rewrite file and enter the contents `--- `
cd ..
comby -templates templates -f ./file

Note that comby will by default treat comments for a language like whitespace, so if you want to rewrite the actual comment, perhaps use comby -templates templates -f ./file -matcher .txt.

Note that this problem is very specific to the -- pattern, anything else should not be a problem. Sorry about that! I'll come up with a fix soon, but there will be some delay to cut a release and so on, so the workaround above is the quickest way for now.

rvantonder avatar Jan 24 '20 04:01 rvantonder