Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piping (Command line options) #39

Open
syxolk opened this issue Jun 14, 2017 · 4 comments
Open

Piping (Command line options) #39

syxolk opened this issue Jun 14, 2017 · 4 comments
Assignees

Comments

@syxolk
Copy link
Collaborator

syxolk commented Jun 14, 2017

Currently we have this:

  • indentex [DIRECTORY]
  • indentex [FILE]

What I want to add:

  • indentex [FILE] --stdout (write to stdout)
  • indentex -o [OUTFILE] (read from stdin)
  • indentex --stdout (read from stdin and write to stdout)
  • indentex [FILE] -o [OUTFILE] (no piping at all; just here for consistency)

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
Copy link
Owner

mp4096 commented Jun 17, 2017

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
Copy link
Owner

mp4096 commented Jun 17, 2017

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
Copy link
Collaborator Author

syxolk commented Jun 24, 2017

  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
Copy link
Owner

mp4096 commented Jun 25, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants