Closed codenamev closed 8 years ago
What do you mean under CLI?.. If command-line interface, there is bin/reality
included (and described in README)
I do mean command-line interface, and I don't see any reference to command-line usage in the README. Also, the existing bin/reality
is pretty unusable as a command line tool since it just opens up an IRB console and doesn't actually expose any of the data directly to IO.
What I'd like to do is expose the results to the command-line so that I can do something like really describe 'reality'
in the command line and it would proxy Entity('reality').describe
.
Oh, ok, understood now! This thing should be useful, I'd like to see pull-request with it.
Console binary is (briefly) mentioned here: https://github.com/molybdenum-99/reality#uhm-ok-how-to-use-it and in several other places, but it has another goals.
Nice idea
Is there a way to access list elements with really
?
$ bin/really "return of the jedi" producers [1]
Error: [#<Reality::Entity?(Rick McCallum)>, #<Reality::Entity?(Howard Kazanjian)>] doesn't respond to [1]
The command line arguments for the really
command are treated as a method chain, with the exception that you can't provide arguments that are methods that take arguments themselves (as is your example with []
). So instead, this string of arguments should give you what you expect: bin/really "return of the jedi" producers first
I am aware of that. But since the response is often a list, I think there should be support for obtaining list elements naturally, other than the first
. Unless a better way comes to mind, I would love to see special handling of [n]
arguments, or even better (more natural) to simply allow numbers without square brackets - really "return of the jedi" producers 2 awards 1
Something along the lines of if subcommand is a number and object respond to [] then...
Edit: Something like this branch
And then you do:
bin/really "wikipedia" founders 1 occupations 1
Its quick and dirty, just to get boots on the ground.
My thinking with round one here was to expose the raw output as much as possible. You can achieve fetching of specific nth result by piping the output to the sed
command. Something like ... | sed -n 1p
will give you the first match. You can even use sed
to grab ranges.
I think it may make sense to introduce more "filters" when interacting with lists, but I think for now it'd be better to gauge community use and see what features are demanded once it's been out in the wild ;-)
I agree with @codenamev on it. Next release of reality is scheduled to April 9, and the really
command will be promoted in release notes, and then we'll see what people say. (Though @DannyBen's implementation is pretty witty and minimalistic, I should say.)
Fair enough. Also.... while the window of opportunity is still open, I would like to raise the issue of naming.
Although I love really
for the command line, I would consider reducing the bin count to one.
Advantages:
reality
gem has a reality
bin, a common pattern in other gems that expose a binary.So, an alternative to having reality
+ really
can be:
reality --console
- to run console
reality QUERIES
- to run the CLI
Hmm, yes, I've thinked on this already, but haven't come to any concrete solution. The --console
vs QUERIES
thing looks quite reasonable, though. WDYT, @codenamev?
@zverok I agree with @DannyBen that there should be a single command. I think it would make more sense to default to the "console" version as that seems to be a best practice amongst gems. The current command is more of an "interactive Reality shell" than it is a CLI.
If you agree, maybe something like reality --interactive
and/or reality -i
? Just thinking of how git
handles it for rebasing. I can whip this up in another PR pretty quickly if you guys like it.
If you agree, maybe something like
reality --interactive
and/orreality -i
? Just thinking of how git handles it for rebasing. I can whip this up in another PR pretty quickly if you guys like it.
Totally fine for me!
Closed with 42c7acf116fc3e990368ce0df67d0c042c21be1b (which is now in master).
Is there any interest in a CLI for this? I made a quick script to expose the
describe
method, but if anyone else would find this useful I wouldn't mind contributing it.This is an awesome gem by the way :smile: