Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Allow scanning to print to stdout #15

Open
tonglil opened this issue Dec 9, 2016 · 2 comments
Open

Allow scanning to print to stdout #15

tonglil opened this issue Dec 9, 2016 · 2 comments

Comments

@tonglil
Copy link
Owner

tonglil commented Dec 9, 2016

Instead of forcing a destination file, print the scan result to stdout if a file is not provided.

@tonglil
Copy link
Owner Author

tonglil commented Feb 9, 2017

Can be done, but is it desirable?

  • Update scan.go to accept no args or a --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
	}
}
  • Skip file operations in reader.go if flag is set.
  • Write to stdout instead of file in reader.go.

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.

@tonglil
Copy link
Owner Author

tonglil commented Feb 9, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant