Open tonglil opened 7 years ago
Can be done, but is it desirable?
--stdout
flag.Refactor scan.go to create the Options object via a function that checks for an ""
Filename
and sets a private var to print to stdout, maybe like:
func NewOptions(dryrun, repo pflag.Flag, file string) Options {
opt := &types.Options{
DryRun: dryrun.Changed,
Repo: repo.Value.String(),
Filename: file,
}
if file == "" {
opt.Stdout = true
}
}
Could be better served by big refactoring of Options to hold a file open, than just the filename. Or change config.Write to satisfy some interface.
But the question is why do this? Dry run is already pretty decent and scanning into a file is just a matter of git reset
to revert the scan results.
Instead of forcing a destination file, print the scan result to stdout if a file is not provided.