Parquery / gocontracts

A tool for design-by-contract in Go
MIT License
111 stars 7 forks source link

Process multiple files at once #31

Closed KantarBruceAdams closed 5 years ago

KantarBruceAdams commented 5 years ago

The tool currently supports only processing one file at a time. For example:

ls hello.go hello_test.go gocontracts *.go Expected the path to the file as a single positional argument, but got positional 2 argument(s)

This would make it less convenient to use in production.

mristin commented 5 years ago

I'm working on this issue. It should be done by tomorrow.

mristin commented 5 years ago

Hi @KantarBruceAdams While implementing the feature, I realized that it's rather confusing for the user to process multiple files as gocontracts outputs the code to stdout by default. Processing multiple files would add a confusing constraint to the command-line arguments that you have to process files in-place if you specify multiple.

If you are using linux, you can always call:

``bash find . -name "*.go" -exec gocontracts -w {} \;



Since `go fmt` follows the same convention, I finally decided to stick with it.

Once we add invariants, I'll add support for recursive iteration over packages. (I plan to work on invariants in Jan-Mar 2019).
KantarBruceAdams commented 5 years ago

rather than output to stdout it would make more sense to require an output directory. E.g. four usages: gocontracts gocontracts gocontracts -w gocontracts -w

Of course you can use bash for anything that does a single file at a time but I was thinking to internalize the boilerplate

mristin commented 5 years ago

@KantarBruceAdams, I had another look at the code, but there is no easy way to keep the inferface simple. I suppose that's also reflected in the design of gofmt.

I'll start to implement invariants in March 2019 which will require gocontracts to operate on packages, and I'll add recursion there.