Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7098fb067e | ||
|
9dff015945 | ||
|
461dee5b69 | ||
|
241b0006fc |
12
Makefile
Normal file
12
Makefile
Normal file
|
@ -0,0 +1,12 @@
|
|||
.PHONY: all bin
|
||||
|
||||
|
||||
all:
|
||||
OS=linux ARCH=amd64 make bin
|
||||
OS=darwin ARCH=amd64 make bin
|
||||
OS=plan9 ARCH=amd64 make bin
|
||||
7z a hdiet.zip *.bin Readme.md
|
||||
|
||||
bin: hdiet.go go.mod
|
||||
GOOS="$(OS)" GOARCH="$(ARCH)" CGO_ENABLED=0 go build -o "hdiet-$(OS)-$(ARCH).bin" -ldflags '-s -w' hdiet.go
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
hdiet
|
||||
========
|
||||
|
||||
hdiet is an adaptation of the Hacker's Diet computer tools for weight tracking. You can find releases at [releases.gutmet.org](https://releases.gutmet.org) or build it yourself.
|
||||
hdiet is an adaptation of the Hacker's Diet computer tools for weight tracking.
|
||||
|
||||
The Hacker's Diet
|
||||
=================
|
||||
|
@ -13,7 +13,7 @@ Walker provides excellent online tools for tracking and Excel-/Palm-based tools
|
|||
build
|
||||
=====
|
||||
|
||||
You need go v1.9 or higher. If you have go module support enabled, check the repository out wherever and run <i>go build hdiet.go</i> - otherwise use go get.
|
||||
You need go v1.20 or higher. Check the repository out wherever and run <i>go build</i>.
|
||||
|
||||
usage
|
||||
=====
|
||||
|
@ -48,9 +48,9 @@ Example
|
|||
|
||||
Example of a filled weight log:
|
||||
|
||||
![](../plain/weight_example.png)
|
||||
![](weight_example.png)
|
||||
|
||||
|
||||
Example of a trend graph without calculated diet:
|
||||
|
||||
![](../plain/plot_example.png)
|
||||
![](plot_example.png)
|
||||
|
|
6
hdiet.go
6
hdiet.go
|
@ -72,7 +72,7 @@ func log(args []string) error {
|
|||
if !isInitialized() {
|
||||
return errNotInitialized()
|
||||
}
|
||||
if len(args) != 1 {
|
||||
if len(args) < 1 {
|
||||
return errors.New("log: Please provide weight as argument (floating point number)")
|
||||
}
|
||||
weight, err := strconv.ParseFloat(args[0], 64)
|
||||
|
@ -80,10 +80,12 @@ func log(args []string) error {
|
|||
return errors.New("log: " + err.Error())
|
||||
}
|
||||
date := time.Now().Format(dateLayout)
|
||||
err = goutil.AppendToFile(logfile, fmt.Sprintf("%s\t%.1f\n", date, weight))
|
||||
newline := fmt.Sprintf("%s\t%.1f\t%s\n", date, weight, strings.Join(args[1:], " "))
|
||||
err = goutil.AppendToFile(logfile, newline)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Print(newline)
|
||||
return show(showFlags{})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user