rabbitmq / rabbitmq-cli

Command line tools for RabbitMQ
Other
105 stars 34 forks source link

Provide a way to evaluate a file with code #438

Closed lukebakken closed 4 years ago

lukebakken commented 4 years ago

Currently you are forced to get shell quoting exactly right, which is very difficult due to the interaction between Erlang syntax and shell quoting rules. On Windows, this becomes even more difficult.

The eval subcommand should be able to read Erlang clauses from a file and execute them.

michaelklishin commented 4 years ago

I think a new command, e.g. eval_file [path] would be best.

gerhard commented 4 years ago

Would it make sense for rabbitmqctl eval to work with STDIN?

If yes, then this could be used in a number of ways, including part of a UNIX pipeline:

[SOME CODE] | [MORE CODE] | rabbitmqctl eval

cat FILE | rabbitmqctl eval

rabbitmqctl eval < FILE

rabbitmqctl eval <<< [STRING_AS_STDIN]

By the way, how does STDIN work on Windows?

michaelklishin commented 4 years ago

Supporting stdin is also a good idea.

lukebakken commented 4 years ago

By the way, how does STDIN work on Windows

cmd.exe supports pipes, and powershell probably has better options, but the best way on Windows will be to read a file.

michaelklishin commented 4 years ago

This is why I think we should both add a new command to eval a file and support stdin for the command we have.