Option to list files that will be modified
mithun opened this issue · comments
The capability to list files that will be modified, but without modifying them, will be very useful.
This will also allow addlicense
to be used in CI environments, git-hooks, etc., to ensure licensing compliance.
#25 added a -v
flag (verbose) to print files which are modified. You could use it to achieve the same effect.
But all that wouldn't help much in a CI environment because what you really want is a more clear signal to indicate whether at least one file is missing a license. You wouldn't want to inspect the output every time, especially in automated scripts and CIs.
What you probably want is for addlicense
to exit with a specific code if at least 1 file missing a license. Then you could easily use that in hooks and CIs.
OTOH it isn't clear what zero exit code would mean then. Is it "ok, all files already have a license; none were modified" or "ok, added license where missing; all files now have a license".
Currently, there's no distinction and zero exit code simply means: ok, all files known to the program have a license now regardless of whether any of them were modified.
#25 added a -v flag (verbose) to print files which are modified. You could use it to achieve the same effect
Well, not really. The -v
flag is still potentially modifying files.
What you probably want is for addlicense to exit with a specific code if at least 1 file missing a license. Then you could easily use that in hooks and CIs.
Yes.
Currently, there's no distinction and zero exit code simply means: ok, all files known to the program have a license now regardless of whether any of them were modified.
I agree.
This issue is for a new flag --check
(or something appropriately named) that implements the following behavior: Running addlicense --check <pattern>
must:
- Never modify any files
- Exit with zero (success) if all files in
<pattern>
have a license - Exit with non-zero (failure, exit code
1
) if at least one file in the<pattern>
requires modification to include a license text. Additionally, print such files toSTDOUT
.
Yeah, that's precisely it. Would you mind sending a pull request?
Yeah, that's precisely it. Would you mind sending a pull request?