Ask questionsdeno eval

Add new subcommand for evaluating on the command line

> deno eval "console.log('hello')"

Would be cool to have some examples of using Deno.stdin along with this feature in the to do unix-style line processing. Here's an imaginary command which prints all of the users on the system (note that Deno.lines is not implemented)

> cat /etc/passwd |  deno eval " \
  for await (let line of Deno.lines(Deno.stdin) { \
    console.log(line.split(':')[0]) }"

Answer questions ry

@rsp You bring up a couple of different ideas - I will try to address them individually

  1. "deno eval" means you cannot execute a javascript file named "eval". That's a good point and I hadn't considered. Maybe it's not such a big deal since there's only a finite number of subcommands. As long as you avoid "fmt" "eval" "types" and a few others it should still be possible to use extensionless scripts...

  2. The case against only using traditional unix flags (and no subcommands) is this: not all flags are appropriate in every combination. For example, if "deno fmt" was instead "deno --fmt" then it wouldn't make sense to also combine it with "--info".

  3. Regarding the whitelisted directories (and network connections): this keeps coming up, so I think we'll have to implement this.

  4. Regarding single letter switches. I don't really know the final shape of the CLI flags so in general I'm trying to be conservative in adding flags (especially abbreviated ones). I would like to postpone committing to single letter switches for now.

  5. filt looks amazing. I would love for deno to support such succinct command line examples.

@bartlomieju While that seems very useful, I don't want to unilaterally introduce new file formats. (That's how we got package.json.) Maybe there is something in the web package standards that is applicable. In any case, I think this is something we can punt on for a few months.