Skip to content

Commit

Permalink
Add version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
michenriksen committed Apr 27, 2019
1 parent b421c05 commit 1ad1db0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Automatic SSL/TLS detection on non-standard ports
- URL Screenshotter agent now takes extra steps to ensure that the browser process is killed after use
- Version flag to output current version (woah!!!)

### Changed
- Packages and other dependencies have been updated to latest versions
Expand Down
2 changes: 2 additions & 0 deletions core/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Options struct {
SaveBody *bool
Silent *bool
Debug *bool
Version *bool
}

func ParseOptions() (Options, error) {
Expand All @@ -37,6 +38,7 @@ func ParseOptions() (Options, error) {
SaveBody: flag.Bool("save-body", true, "Save response bodies to files"),
Silent: flag.Bool("silent", false, "Suppress all output except for errors"),
Debug: flag.Bool("debug", false, "Print debugging information"),
Version: flag.Bool("version", false, "Print current Aquatone version"),
}

flag.Parse()
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ func main() {
os.Exit(1)
}

if *sess.Options.Version {
sess.Out.Info("%s v%s", core.Name, core.Version)
os.Exit(0)
}

fi, err := os.Stat(*sess.Options.OutDir)

if os.IsNotExist(err) {
Expand Down

0 comments on commit 1ad1db0

Please sign in to comment.