diff options
author | Joop Kiefte <ikojba@gmail.com> | 2019-01-12 23:59:13 +0100 |
---|---|---|
committer | Joop Kiefte <ikojba@gmail.com> | 2019-01-12 23:59:13 +0100 |
commit | e8e1394e0f50794d0558571c806e84c953ff1a31 (patch) | |
tree | 03bda384eb6934c3b3a27263dfdc694f316cb707 | |
parent | 7813670abf4ec55f819e0c26c2300a274672bf08 (diff) |
Make command much more intuitive, getting more options automatically.
-rw-r--r-- | main.go | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -14,6 +14,7 @@ import ( "io" "log" "os" + "strings" ) func main() { @@ -43,6 +44,21 @@ func main() { return } + ins := strings.SplitN(*input, ".", 2) + if len(ins)==2 && *from == "" { + *from = ins[1] + } + outs := strings.SplitN(*output, ".", 2) + if len(outs)==2 && *to == "" { + *to = outs[1] + } + if *from == "" { + *from = "fountain" + } + if *to == "" && *output == "-" { + *to = "lex" + } + var infile io.Reader var outfile io.Writer var i lex.Screenplay @@ -65,6 +81,9 @@ func main() { outfile = os.Stdout log.Println("Writing to Stdout") } else { + if *output == "" && len(ins) > 0 && ins[0] != "" { + *output = ins[0] + "." + *to + } var err error outfile, err = os.Create(*output) if err != nil { @@ -86,11 +105,16 @@ func main() { log.Println("Output type is ", *to) switch *to { case "pdf": + if *output == "-" && len(ins) > 0 && ins[0] != "" { + *output = ins[0] + ".pdf" + } if *output == "-" { log.Println("Cannot write PDF to standard output") return } - log.Println("While the PDF output of this tool is acceptable for most purposes, I would recommend against it for sending in your screenplay. For command line usage, the Afterwriting commandline tools and e.g. the latex export of emacs fountain-mode look really good.") + log.Println("No external PDF tool found, using built-in PDF output.") + log.Println("Disadvantages of built-in PDF: non-English not truly supported, no inline markup.") + log.Println("Advantages of built-in PDF: very fast (perfect for drafts) and reasonable configurability.") pdf.Create(*output, conf.Elements[*elements], i) case "lex": lex.Write(i, outfile) |