-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
Sql results missing when script is invoked from keybind #1400
Comments
Yes, this is somewhat intentional since I didn't want SQL operations that were used in implementing hotkeys to clobber the contents of the DB view. But, yes, there needs to be a way direct where query output goes. |
Ah yeah that makes sense. For some reason I was thinking that the way it worked was that if the last line of a script was a query that returned multiple rows then it would populate the db, otherwise it would not (so all of the intermediate queries wouldn't clobber the db view). But yeah I can see that getting iffy. Were you thinking something like |
Yes, probably a command like this to specify where results are directed to. I'll think about it a bit. |
Not sure if this helps your decision on this but I thought I'd add that scripts that depend on the currently selected line in the db view are fairly restricted to using I can understand it still might be a bit of a pain from scripting perspective because presumably the table schema of And maybe |
Can you go into a little more detail here? You mentioned opening a file from a list as one use case, do you have some others in mind?
I've thought about dumping the query results into a SQLite table instead of storing them internally. But, I just got done redoing the guts of the DB view to use a purpose-built data structure that is compact/performant and serves the needs of the view pretty directly. So, I don't want to ditch that work. One alternative you could use would be to create a separate table that holds the extra information that you need to do the operations you want. Then you don't have to parse the display contents. You can get the Another alternative I would suggest investigating is to have the scripts output markdown. That gives you a lot more control of the display and you can use links to open stuff and execute commands. The tutorial is built around markdown and SQLite triggers. The user can then just click a link instead of having to remember a hotkey. As an example, in v0.12.4, I added this report-access-log script that generates a markdown file that has links that can be used to run queries. The links refer to properties in the YAML front matter. The front matter has the operations that to execute. So, I could imagine implementing the script that opens source files by generating some markdown with either links to the files themselves or links that run If you want to share some of your use cases, I could help prototyping scripts to do what you want (and make sure lnav actually works correctly). |
I think the main script I was thinking about was the listing files, that can be opened one. I assumed that there may be other use cases for this but it definitely could just be this 1 niche application. I can think of other similar scripts I might want but those might be better suited for the md link way. ( I think I like the files in db view more because I can have different columns for
This is what I've ended up going with so far, but the downside of this approach is that if someone wanted to query the
Ty for this I'll keep this in mind when considering scripts that require user-input in the future! |
In a script called
test.lnav
If the script is invoked via cmd line by typing
|test
then the db view will be populated with 1..6 and the view will toggle to db view.However if this script is invoked by pressing a key that is bound to running the script:
The db view will not be populated.
The text was updated successfully, but these errors were encountered: