Compare commits

..

4 Commits

Author SHA1 Message Date
gutmet
7098fb067e allow arbitrary strings after weight value in 'log' command 2025-01-12 22:21:54 +01:00
gutmet
9dff015945 fix readme again 2023-09-21 23:06:21 +02:00
gutmet
461dee5b69 fix readme 2023-09-21 23:02:11 +02:00
gutmet
241b0006fc add makefile 2023-09-21 22:51:51 +02:00
3 changed files with 20 additions and 6 deletions

12
Makefile Normal file
View 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

View File

@ -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)

View File

@ -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{})
}