Open ramanshah opened 7 years ago
Current usage:
bread ciabatta.yml 1.2
Current feature set:
Desired feature set:
Seems like two optional command line flags would do it:
-y
to request YAML output.-d
to divide by another scalar.Usage like this for the desired feature set?
bread ciabatta.yml 1.2
bread ciabatta.yml 1.2 -y
bread ciabatta.yml 100 -d 123
bread ciabatta.yml 100 -d 123 -y
Perhaps we could auto-detect the denominator if the command line takes the correct format:
bread ciabatta.yml 1.2
bread ciabatta.yml 1.2 -y
bread ciabatta.yml 100 123
bread ciabatta.yml 100 123 -y
The Alternative
feature of optparse-applicative
seems to be a way to do the latter.
In terms of work I did at the recent hackathon, a good order of work would be:
optparse-applicative
dependency.-y
flag to use the ToJSON
boilerplate I got working.One idea is to use hascal
and migrate the scale factor to a quoted string.
Unfortunately this seems to have been scrubbed from the web by its maintainer, and it didn't make it into a Stack LTS. Alternatives:
In any case, these would be the kinds of commands envisioned:
bread ciabatta.yml 1.2
bread ciabatta.yml 1.2 -y
bread ciabatta.yml "100 / 123"
bread ciabatta.yml "100 / 123" -y
Whether one can get away without quoting the 1.2 is negotiable.
bread
is already nice in scaling published recipes at bake time, but it would be nice to re-use the machinery as a utility in developing recipes. Say I nail a recipe in the course of recipe development and want to bring the quantities back to round numbers (say 100 g of flour, reading out a baker's percentage) and then publish that recipe as YAML.Often this task will involve multiplying by a fraction
x/y
. It would be nice to support such a workload ergonomically.