@@ -36,7 +36,32 @@ var uploadCmd = &cobra.Command{
36
36
calories , _ := flags .GetFloat64 ("calories" )
37
37
bmi , _ := flags .GetFloat64 ("bmi" )
38
38
39
- bc := bodycomposition .NewBodyComposition (weight , fat , hydration , bone , boneKg , muscle , muscleKg , visceralFat , physiqueRating , metabolicAge , calories , bmi , ts )
39
+ var boneMass float64
40
+ var muscleMass float64
41
+
42
+ if bone != - 1 && boneKg != - 1 {
43
+ cmd .PrintErrf ("Cannot provide bone weight in percent and bone mass in kg! Use either of both!" )
44
+ os .Exit (1 )
45
+ }
46
+
47
+ if bone != - 1 {
48
+ boneMass = weight * bone / 100
49
+ } else {
50
+ boneMass = boneKg
51
+ }
52
+
53
+ if muscle != - 1 && muscleKg != - 1 {
54
+ cmd .PrintErrf ("Cannot provide muscle weight in percent and muscle mass in kg! Use either of both!" )
55
+ os .Exit (1 )
56
+ }
57
+
58
+ if muscle != - 1 {
59
+ muscleMass = weight * muscle / 100
60
+ } else {
61
+ muscleMass = muscleKg
62
+ }
63
+
64
+ bc := bodycomposition .NewBodyComposition (weight , fat , hydration , boneMass , muscleMass , visceralFat , physiqueRating , metabolicAge , calories , bmi , ts )
40
65
41
66
email , _ := cmd .Flags ().GetString ("email" )
42
67
password , _ := cmd .Flags ().GetString ("password" )
@@ -71,10 +96,10 @@ func init() {
71
96
flags .Float64P ("weight" , "w" , - 1 , "Set your weight in kilograms" )
72
97
flags .Float64P ("fat" , "f" , 0 , "Set your fat in percent" )
73
98
flags .Float64 ("hydration" , 0 , "Set your hydration in percent" )
74
- flags .Float64P ("bone" , "b" , 0 , "Set your bone mass in percent" )
75
- flags .Float64 ("bone-mass" , 0 , "Set your bone mass in kilograms" )
76
- flags .Float64P ("muscle" , "m" , 0 , "Set your muscle mass in percent" )
77
- flags .Float64 ("muscle-mass" , 0 , "Set your muscle mass in kilograms" )
99
+ flags .Float64P ("bone" , "b" , - 1 , "Set your bone mass in percent" )
100
+ flags .Float64 ("bone-mass" , - 1 , "Set your bone mass in kilograms" )
101
+ flags .Float64P ("muscle" , "m" , - 1 , "Set your muscle mass in percent" )
102
+ flags .Float64 ("muscle-mass" , - 1 , "Set your muscle mass in kilograms" )
78
103
flags .Float64P ("calories" , "c" , 0 , "Set your caloric intake" )
79
104
flags .Float64 ("visceral-fat" , 0 , "Set your visceral fat rating (valid values: 1-60)" )
80
105
flags .Float64 ("metabolic-age" , 0 , "Set your metabolic age" )
0 commit comments