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

Output user query (wizard mode) #119

Closed
FGRibreau opened this issue Jul 1, 2014 · 4 comments
Closed

Output user query (wizard mode) #119

FGRibreau opened this issue Jul 1, 2014 · 4 comments

Comments

@FGRibreau
Copy link

Let say a developer wants to filter something with peco for a script (e.g. a cron), first he wants to try the command itself (and discover the output data with peco), so he runs:

myVar="some script variable"
git grep $myVar | peco --wizard

Peco opens, the dev use the selector to match what he wants (and he can directly see the output in peco, that's what Bret Victor would call instant feedback), then, when he exits, peco prints:

peco --query="myQuery -excludeA -excludeB"

So the developer will just have to put copy/paste the command below inside his script :

myVar="some script variable"
git grep $myVar | peco --query="myQuery -excludeA -excludeB"

PS: I just installed peco so I did not took the time to see how fare the query engine could go. Here "-excludeA" and "-excludeB" are word exclusions.

@lestrrat
Copy link
Contributor

lestrrat commented Jul 1, 2014

So this is actually two issues:

  1. You would like a way to generate the command line that would repeat what you just interactively defined on peco, and
  2. You would like negative match queries.

Neither are really trivial to implement at this point. I'm going to have to sit on it for a little while (esp because it's my bedtime now :) to think if it's feasible and/or something I'd like peco to implement.

So please give me a little time to think about it.
And if you are up for it and can't wait for me, PRs are welcome, too :)

@FGRibreau
Copy link
Author

Don't worry I don't need it right now, I was just sharing the idea, good night from France!

@lestrrat
Copy link
Contributor

lestrrat commented Jul 1, 2014

I slept on it, and here are my initial thoughts:

1. the wizard mode

I think, at least at this point in time, this feature will not be implemented. The reasoning is that this essentially requires us to write that much more code for pretty much every new feature we implement, which would slowdown/demotivate us to add new features. You only refer to --query, but in reality other states such as the current matcher being applied, and if --null is in effect or not, etc would need to be taken into consideration.
I find this overhead to be something that I would not want to impose on us developers. At least not yet, when we're actively adding/dropping features.

2. Negative matches

I'm fine with adding negative matches, as long as there's proper syntax. Things to consider: suppose you used -queryToExclude syntax. What if you really wanted to match a "-" prefix. How do you escape? Also, what happens when you go from IgnoreCase/CaseSensitive mode to Regexp match mode? Does anything change? As long as we can come up with a spec for these things, I think this is doable.
At this point I have really no use for negative matches myself, so it would be nice if somebody interested in this think about it and propose a spec.

@lestrrat
Copy link
Contributor

It's been 3 weeks. I don't think this is going to be implemented any time soon, and even if it does get implemented, it should be broken down into smaller pieces, so will be closing this for now. If you or anybody else is interested, please open a new issue.

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

No branches or pull requests

2 participants