Skip to content

Commit

Permalink
1.0.0. bonniego -version prints version
Browse files Browse the repository at this point in the history
Everyone needs a version, otherwise how will you know that you need to
upgrade?
  • Loading branch information
cunnie committed Feb 14, 2018
1 parent 89e8c5d commit 5ef5276
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ It presents three disk metrics:

## Examples

The default settings are typically adequate; the program can be invoked without
parameters:
`bonniego` can be invoked without parameters; its defaults are reasonable.

```
bonniego
Expand Down Expand Up @@ -72,6 +71,18 @@ flag. In this example, we spawn 8 threads:
bonniego -procs 8
```

`-version` will display the current version of `bonniego`:

```
bonniego -version
```

Yields:

```
bonniego version 1.0.0
```

## Technical Notes

`bonniego` detects the number of CPU cores and the amount of RAM.
Expand Down
9 changes: 8 additions & 1 deletion bonniego.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,28 @@ import (
"time"
)

const Version = "1.0.0"
const Blocksize = 0x1 << 16 // 65,536 bytes, 2^16 bytes

func main() {
var bonnieTempDir, bonnieParentDir, bonnieDir string
var numProcs int
var verbose bool
var verbose, version bool
bonnieTempDir, err := ioutil.TempDir("", "bonniegoParent")
check(err)
defer os.RemoveAll(bonnieTempDir)

flag.BoolVar(&verbose, "v", false, "Verbose. Will print to stderr diagnostic information such as the amount of RAM, number of cores, etc.")
flag.BoolVar(&version, "version", false, "Version. Will print the current version of bonniego and then exit")
flag.IntVar(&numProcs, "procs", runtime.NumCPU(), "The number of concurrent readers/writers, defaults to the number of CPU cores")
flag.StringVar(&bonnieParentDir, "dir", bonnieTempDir, "The directory in which bonniego places its temp files, should have at least twice system RAM available")
flag.Parse()

if version {
fmt.Printf("bonniego version %s\n", Version)
os.Exit(0)
}

// if bonnieParentDir exists, e.g. "/tmp", all is good, but if it doesn't, e.g. "/tmp/bonniego_run_five", then create it
fileInfo, err := os.Stat(bonnieParentDir)
if err != nil {
Expand Down

0 comments on commit 5ef5276

Please sign in to comment.