Diff for /gnutrition/main.c between versions 1.4 and 1.5

version 1.4, 2026/05/12 21:32:44 version 1.5, 2026/05/12 21:50:01
Line 89  print_help (void) Line 89  print_help (void)
           "(for calorie estimation)\n"));            "(for calorie estimation)\n"));
   printf (_("  -H, --height=CM      your height in centimeters\n"));    printf (_("  -H, --height=CM      your height in centimeters\n"));
   printf (_("  -w, --weight=KG      your weight in kilograms\n"));    printf (_("  -w, --weight=KG      your weight in kilograms\n"));
     printf (_("  -G, --gender=NAME    neutral, female, or male\n"));
   printf (_("  -A, --activity=LEVEL activity level: sedentary, light,\n"));    printf (_("  -A, --activity=LEVEL activity level: sedentary, light,\n"));
   printf (_("                         moderate, very-active, or extra-active\n"));    printf (_("                         moderate, very-active, or extra-active\n"));
   printf (_("  -G, --gender=NAME    neutral, female, or male\n"));  
   printf (_("  -d, --date=DATE      date for log/budget "    printf (_("  -d, --date=DATE      date for log/budget "
           "(default: today)\n"));            "(default: today)\n"));
   printf (_("  -D, --db=PATH        path to food database (default: food.db)\n"));    printf (_("  -D, --db=PATH        path to food database (default: food.db)\n"));
Line 100  print_help (void) Line 100  print_help (void)
   printf (_("                         (default: $XDG_DATA_HOME/gnutrition/log.db)\n"));    printf (_("                         (default: $XDG_DATA_HOME/gnutrition/log.db)\n"));
   printf (_("  -h, --help           display this help and exit\n"));    printf (_("  -h, --help           display this help and exit\n"));
   printf (_("  -V, --version        output version information and exit\n"));    printf (_("  -V, --version        output version information and exit\n"));
   printf (_("\nWhen --age, --height, --weight, and --activity are all given,\n"));    printf (_("\nWhen --age, --height, --weight, --gender and --activity are all\n"));
   printf (_("the calorie target is estimated using the Mifflin-St Jeor\n"));    printf (_("given, the calorie target is estimated using the Mifflin-St Jeor\n"));
   printf (_("equation and saved to your profile for future sessions.\n"));    printf (_("equation and saved to your profile for future sessions.\n"));
   printf (_("Use --calories to override the computed estimate.\n"));    printf (_("Use --calories to override the computed estimate.\n"));
   printf (_("\nThe calorie level determines your daily food-group budget\n"));    printf (_("\nThe calorie level determines your daily food-group budget\n"));
Line 460  main (int argc, char **argv) Line 460  main (int argc, char **argv)
   int profile_age;    int profile_age;
   double profile_height;    double profile_height;
   double profile_weight;    double profile_weight;
     int profile_gender;  /* neutral, female, male  */
   int profile_activity;    int profile_activity;
   int profile_gender;  
   int profile_given;  /* bitmask: 1=age, 2=height, 4=weight, 8=activity  */    int profile_given;  /* bitmask: 1=age, 2=height, 4=weight, 8=activity  */
   int mode;  /* 0 = interactive, 1 = search, 2 = info, 3 = log,    int mode;  /* 0 = interactive, 1 = search, 2 = info, 3 = log,
                 4 = budget, 5 = delete, 6 = edit  */                  4 = budget, 5 = delete, 6 = edit  */
Line 494  main (int argc, char **argv) Line 494  main (int argc, char **argv)
   profile_age = 0;    profile_age = 0;
   profile_height = 0.0;    profile_height = 0.0;
   profile_weight = 0.0;    profile_weight = 0.0;
   profile_activity = ACTIVITY_SEDENTARY;  
   profile_gender = GENDER_NEUTRAL;    profile_gender = GENDER_NEUTRAL;
     profile_activity = ACTIVITY_SEDENTARY;
   profile_given = 0;    profile_given = 0;
   mode = 0;    mode = 0;
   delete_id = 0;    delete_id = 0;
Line 610  main (int argc, char **argv) Line 610  main (int argc, char **argv)
           profile_given |= 4;            profile_given |= 4;
           break;            break;
   
           case 'G':
             profile_gender = parse_gender (optarg);
             if (profile_gender < 0)
               {
                 fprintf (stderr, _("%s: unknown gender '%s'\n"),
                          PROGRAM_NAME, optarg);
                 fprintf (stderr, _("Valid options: neutral, female, male\n"));
                 return 1;
               }
             profile_given |= 7;
             break;
   
         case 'A':          case 'A':
           profile_activity = parse_activity (optarg);            profile_activity = parse_activity (optarg);
           if (profile_activity < 0)            if (profile_activity < 0)
Line 623  main (int argc, char **argv) Line 635  main (int argc, char **argv)
           profile_given |= 8;            profile_given |= 8;
           break;            break;
   
         case 'G':  
           profile_gender = parse_gender (optarg);  
           if (profile_gender < 0)  
             {  
               fprintf (stderr, _("%s: unknown gender '%s'\n"),  
                        PROGRAM_NAME, optarg);  
               fprintf (stderr, _("Valid options: neutral, female, male\n"));  
               return 1;  
             }  
           break;  
   
         case 'd':          case 'd':
           date = optarg;            date = optarg;
           edit_date_given = 1;            edit_date_given = 1;
Line 733  main (int argc, char **argv) Line 734  main (int argc, char **argv)
       prof.age_years = profile_age;        prof.age_years = profile_age;
       prof.height_cm = profile_height;        prof.height_cm = profile_height;
       prof.weight_kg = profile_weight;        prof.weight_kg = profile_weight;
       prof.activity_level = profile_activity;  
       prof.gender = profile_gender;        prof.gender = profile_gender;
         prof.activity_level = profile_activity;
       prof.calorie_target = budget_estimate_calories (profile_age,        prof.calorie_target = budget_estimate_calories (profile_age,
                                                       profile_height,                                                        profile_height,
                                                       profile_weight,                                                        profile_weight,
                                                       profile_activity,                                                        profile_gender,
                                                       profile_gender);                                                        profile_activity);
       if (log_save_profile (log_db, &prof) < 0)        if (log_save_profile (log_db, &prof) < 0)
         fprintf (stderr, _("%s: warning: could not save profile\n"),          fprintf (stderr, _("%s: warning: could not save profile\n"),
                  PROGRAM_NAME);                   PROGRAM_NAME);
Line 752  main (int argc, char **argv) Line 753  main (int argc, char **argv)
     }      }
   else if (profile_given != 0)    else if (profile_given != 0)
     {      {
       fprintf (stderr, _("%s: --age, --height, --weight, and --activity "        fprintf (stderr, _("%s: --age, --height, --weight, --gender, and --activity "
                "must all be given together\n"), PROGRAM_NAME);                 "must all be given together\n"), PROGRAM_NAME);
       log_close (log_db);        log_close (log_db);
       db_close (food_db);        db_close (food_db);

Removed from v.1.4  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>