Open hayeah opened 13 years ago
All of the commands in the examples wiki page except for the last one, are examples of the issue.
The issue is apparent the more I try to get something done by chaining shorter idioms with pipes, e.g.
grep -ir 'my_name' . | awk -F: {print $1} | less
While the last example, grep("-ir foo app").map { |l| puts l.split(":").first } , lets me think in the same order, it does require a lot of typing.
The above example also won't work past 1 pipe.
What if you accepted input such as: grep('-ir foo app').pipe(awk '-F: {print $1}').pipe less
or an even more controversial version that would be more shell-like:
grep :ir 'foo' 'app' | awk :F: '{print $1}' | less
I wrote this one thinking the repl method would need to convert the input.
this is one design decision i thought quite a lot about earlier on. i wanted Rubish to have kosher Ruby syntax. It's unfortunate that operators precedence rules out
grep :ir 'foo' 'app' | awk :F: '{print $1}' | less
Did you know about the pipe command in Rubish (it's not documented in the wiki). It's minimizes the number of keystrokes requires to move from a command to a pipe, while staying proper Ruby syntax.
p { cmd1; cmd2; cmd3 }
The advantage of using ";" is that we don't have to close the parentheses. To transform a command into a pipe, the overhead is 5 key strokes, in two "chunks" of edits
cmd1 "a", "b"
p { cmd1 "a", "b" ; cmd2 }
I don't think it's a good idea to introduce meta syntax, because that makes the shell unpredictable, and works against a clean integration with normal Ruby.
an alternative syntax could be
(cmd1 arg1, arg2) | (cmd2 arg2) | (cmd3 args)
cmd1(arg1, arg2) | cmd2(arg2) | cmd3(args)
I like cmd1(arg1, arg2) | cmd2(arg2) | cmd3(args)
The problem with 'p { .. }' is that one needs to first think about the pipe. I found nearly all the time that I typed in a command, then realised I needed a pipe, then had to move the cursor a lot to include all the commands inside the braces for p.
cool. you've got a great point. we'll use the | operator for piping commands
as I must think about the piping first in order to write the cmd