mp4096 / indentex

An indentation-based superset of LaTeX
MIT License
9 stars 2 forks source link

Piping (Command line options) #39

Open syxolk opened 7 years ago

syxolk commented 7 years ago

Currently we have this:

What I want to add:

It's a bit weird to have the --stdout in the first place but I don't see any other way to stay compatible.

mp4096 commented 7 years ago

Hm, a couple of points:

  1. This will require quite a lot of changes in the code, e.g. breaking down some functions and introducing new ones. You've been already working on it in the piping branch.
  2. I'd prefer explicit over implicit. Why not have an --stdin flag?
  3. I'd prefer -t/--to and -f/--from flags as in pandoc instead of -o. The latter does not have a 'from' or 'input' counterpart, does it?

Apart from this: I find the multi-nesting if-else if-else branches really clumsy and un-elegant. Do you know a fancy pattern for this? The only thing I can think of is matching on tuples:

match (flag_a, flag_b, flag c) {
    (true, false, false) => foo(),
    (false, true, false) => bar(),
    _ => (), // invalid combination
}
mp4096 commented 7 years ago

Thinking about it: Why not --to-stdout and --from-stdin flags? I'd rather type 10 chars more than have inconsistent and ad-hoc flags/commands (like git, unfortunately).

syxolk commented 7 years ago
  1. Most changes are now in main.rs.
  2. I tried to mimic the behavior of gcc. However, it's probably better to require a special flag to use standard input instead of making assumptions if no input file is given.
  3. Adding --from would not be easily backwards-compatible.
mp4096 commented 7 years ago

Ok, I'll take a look at it today!