7.3. Using recipes
Prev | Chapter 7. Adding recipes | Next

## 7.3. Using recipes

You can use a Pantry XML file that contains recipes just as you would use any Pantry file. As we discussed earlier when we talked about creating foods, I would recommend adding the contents of a Pantry XML file to a Pantry native file, because Pantry works with native files much faster than it works with XML files.

Example 7.6. Using a Pantry XML file

    $ pantry --name "Omari's Chili" --print traits-units-nuts \
    > recipes.xml
    Omari's Chili
    1 serving (364g)
       serving
       cup
    Nutrient                  Amount         %G     %TOT
    -------------------------------------------------------
    Calories                  287  kcal       14     100
    Total Fat                 5    g          7      100
    Saturated Fat             1    g          6      100
    Cholesterol               30   mg         10     100
    Sodium                    1052 mg         44     100
    Total Carbohydrate        44   g          15     100
    Dietary Fiber             11   g          43     100
    Sugars                    8    g          NA     100
    Protein                   20   g          40     100
    Vitamin A                 591  IU         12     100
    Vitamin C                 33   mg         55     100
    Calcium                   124  mg         12     100
    Iron                      5    mg         29     100

Example 7.7. Adding a recipe to a Pantry native file

    $ pantry --name "Omari's Chili" --add master recipes.xml

    $ pantry --name "Omari's Chili" --print names master
    Omari's Chili

Now that you know how to create recipes, you will find that there are several additional reports that will come in handy when you are using the `--print` option. You can use all the reports you have already learned about; they work identically with both regular foods and with recipes. The most handy additional report is the `recipe` report. It gives you a plain-text representation of a recipe, along with some additional handy information such as the weight of each ingredient:

Example 7.8. The `recipe` report

    $ pantry --name "Omari's Chili" --print recipe master
    Omari's Chili
    6 quart pot (2181g)

    1/2 lb (8.000oz, 227g) Poultry food products, ground turkey, raw
    1 medium (2-1/2" dia) (3.880oz, 110g) Onions, raw
    1 medium (approx 2-3/4" long, 2-1/2" dia) (4.198oz, 119g) Peppers, sweet, green, raw
    15 oz (15.000oz, 425g) Beans, pinto, mature seeds, canned
    15 oz (15.000oz, 425g) Beans, black turtle soup, mature seeds, canned
    15 oz (15.000oz, 425g) Beans, kidney, all types, mature seeds, canned
    14.5 oz (14.500oz, 411g) Tomatoes, red, ripe, canned, packed in tomato juice
    1 can (6 oz) (5.996oz, 170g) Tomato products, canned, paste, with salt added
    2 cup 8 fl oz (16.720oz, 474g) Water, tap, drinking

    Cook turkey, onions, and bell peppers together in 6-quart stockpot until turkey is crumbly and onions are soft. Rinse beans, and toss into pot with remaining ingredients. Cook until thickened.

    Add spices, such as chili powder, red pepper, salt, oregano, garlic powder, and cumin, to taste.

You can get the same information by using `--print names-yield-blank-ingredients-blank-directions`, but `--print recipe` is a bit shorter to type. You can use the other reports, such as `ingredients`, if you're only interested in a subset of the information. Of course, you can combine the `recipe` report with other Pantry reports. You can also use handy utilities such as fold, which should already be installed if you are using a GNU operating system.[19] This gives you nice printer-ready output that you can feed to lp:

Example 7.9. Using the `recipe` report with other cool stuff

    $ pantry --name "Omari's Chili" --print recipe-blank- \
    > traits-nuts master | fold --spaces --width=68
    Omari's Chili
    6 quart pot (2181g)

    1/2 lb (8.000oz, 227g) Poultry food products, ground turkey, raw
    1 medium (2-1/2" dia) (3.880oz, 110g) Onions, raw
    1 medium (approx 2-3/4" long, 2-1/2" dia) (4.198oz, 119g) Peppers,
    sweet, green, raw
    15 oz (15.000oz, 425g) Beans, pinto, mature seeds, canned
    15 oz (15.000oz, 425g) Beans, black turtle soup, mature seeds,
    canned
    15 oz (15.000oz, 425g) Beans, kidney, all types, mature seeds,
    canned
    14.5 oz (14.500oz, 411g) Tomatoes, red, ripe, canned, packed in
    tomato juice
    1 can (6 oz) (5.996oz, 170g) Tomato products, canned, paste, with
    salt added
    2 cup 8 fl oz (16.720oz, 474g) Water, tap, drinking

    Cook turkey, onions, and bell peppers together in 6-quart stockpot
    until turkey is crumbly and onions are soft. Rinse beans, and toss
    into pot with remaining ingredients. Cook until thickened.

    Add spices, such as chili powder, red pepper, salt, oregano, garlic
    powder, and cumin, to taste.

    Omari's Chili
    1 serving (364g)
    Nutrient                  Amount         %G     %TOT
    -------------------------------------------------------
    Calories                  287  kcal       14     100
    Total Fat                 5    g          7      100
    Saturated Fat             1    g          6      100
    Cholesterol               30   mg         10     100
    Sodium                    1052 mg         44     100
    Total Carbohydrate        44   g          15     100
    Dietary Fiber             11   g          43     100
    Sugars                    8    g          NA     100
    Protein                   20   g          40     100
    Vitamin A                 591  IU         12     100
    Vitamin C                 33   mg         55     100
    Calcium                   124  mg         12     100
    Iron                      5    mg         29     100

Now that you know how to create both foods and recipes, you can create them both in the same Pantry XML file.

[19] Non-GNU UNIX systems will likely have a fold utility installed, but it might not have handy options such as `--spaces`. Windows won't have fold at all.

Prev | Up | Next
7.2. Creating a recipe | Home | Appendix A. Reference pages