sets echo on by default with read from file flag

This commit is contained in:
NunoSempere 2024-11-10 17:07:19 +00:00
parent a99934387c
commit 27f9932db8
3 changed files with 5 additions and 3 deletions

View File

@ -4,7 +4,7 @@ This project is a minimalist, calculator-style DSL for fermi estimation. It can
## Motivation
Sometimes, [Squiggle](https://github.com/quantified-uncertainty/squiggle), [simple squiggle](https://git.nunosempere.com/quantified.uncertainty/simple-squiggle) or [squiggle.c](https://git.nunosempere.com/personal/squiggle.c) are still too complicated and un-unix-like.
Sometimes, [Squiggle](https://github.com/quantified-uncertainty/squiggle), [simple squiggle](https://git.nunosempere.com/quantified.uncertainty/simple-squiggle) or [squiggle.c](https://git.nunosempere.com/personal/squiggle.c) are still too complicated and un-unix-like. In particular, their startup cost is not instant.
## Installation
@ -94,7 +94,7 @@ Command flags:
-echo
Specifies whether inputs should be echoed back. Useful if reading from a file
. -f string
Specifies a file with a model to run
Specifies a file with a model to run. Sets the echo command to true by default.
-n int
Specifies the number of samples to draw when using samples (default 100000)
-h Shows help message
@ -194,6 +194,7 @@ Done:
To (possibly) do:
- [ ] With the -f command line option, the program doesn't read from stdin after finishing reading the file
- [ ] Add functions. Now easier to do with an explicit representation of the stakc
- [ ] Think about how to draw a histogram from samples
- [ ] Dump samples to file

BIN
fermi

Binary file not shown.

View File

@ -459,7 +459,7 @@ replForLoop:
func main() {
num_samples_flag := flag.Int("n", N_SAMPLES, "Specifies the number of samples to draw when using samples")
filename := flag.String("f", "", "Specifies a file with a model to run")
filename := flag.String("f", "", "Specifies a file with a model to run. Sets the echo flag to true")
echo_flag := flag.Bool("echo", false, "Specifies whether inputs should be echoed back. Useful if reading from a file.")
help_flag := flag.Bool("h", false, "Shows help message")
flag.Parse()
@ -472,6 +472,7 @@ func main() {
if *filename != "" {
file, err := os.Open(*filename)
if err == nil {
*echo_flag = true
reader = bufio.NewReader(file)
} else {
fmt.Printf("Error opening filename; reading from stdin instead\n")