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

:write_output & :clear_output, --verb_output #834

Merged
merged 3 commits into from
Feb 21, 2024
Merged

:write_output & :clear_output, --verb_output #834

merged 3 commits into from
Feb 21, 2024

Conversation

Canop
Copy link
Owner

@Canop Canop commented Feb 11, 2024

Fix: #825

Add a --verb-output launch argument which takes a path to a file (which will be created if necessary)

Add a :write_output internal which allows adding a line to that file. No escaping is done (contrary to what happens with --outcmd).

Add a :clear_output internal which clears the file.

Here are 2 examples of verbs:

    {
        invocation: "wc {cmd}"
        execution: ":write_output wc:{cmd} {file-stem}.bro"
    }

    {
        key: alt-w
        cmd: ":clear_output;:write_output {directory};:quit"
    }

The first one is called with an input like :wc hop which appends to the output a line like wc:hop main.bro.

The second one makes the content of the output file the directory closest to the selection then quits. It could for example be used for a new version of the br shell function.

Note: Semantics isn't pretty. If you have a better idea than "output", please tell me.

@AndydeCleyre
Copy link

Thanks so much!

In my first tests, this seems almost working right, but for some reason the following verb does not quit broot. If I call the verb then manually quit it does seem to work as intended though.

  {
    key: alt-enter
    invocation: cd
    internal: ":write_output {directory}"
    leave_broot: true
  }

@Canop
Copy link
Owner Author

Canop commented Feb 14, 2024

Today, internals don't even check the leave_broot setting of the verb. For most of them, quitting would be totally unexpected (think for example about "line_down", or "open_preview").

That's why my example in the PR description had an explicit :quit.

Maybe some internals could check it ?

@AndydeCleyre
Copy link

I've been using :print_path with leave_broot: true, but I guess leaving broot is part of that internal's behavior anyway? Haven't tried it with false...

OK yeah I'll make it a cmd with quit, thanks!

@AndydeCleyre
Copy link

Maybe an interesting quoting issue?

  {
    key: alt-enter
    invocation: cd
    cmd: ":write_output {directory};:quit"
  }

No verb matches "quit\""

@Canop
Copy link
Owner Author

Canop commented Feb 14, 2024

This works for me

@AndydeCleyre
Copy link

Oh, I tried to use it on a folder named

with " a quote and spaces

@AndydeCleyre
Copy link

Also happens with a folder named just sp ac

@Canop
Copy link
Owner Author

Canop commented Feb 14, 2024

Ok... I suspected there was a bug in sequence interpolation... back to draft mode!

@Canop Canop marked this pull request as draft February 14, 2024 19:38
@Canop Canop marked this pull request as ready for review February 19, 2024 19:44
@Canop
Copy link
Owner Author

Canop commented Feb 19, 2024

@AndydeCleyre back to testable

@AndydeCleyre
Copy link

This seems to be working great with my weird folder names, thanks!

@Canop Canop merged commit 829a67f into main Feb 21, 2024
1 check passed
@Canop Canop deleted the verb-output branch February 21, 2024 08:59
@Canop
Copy link
Owner Author

Canop commented Feb 21, 2024

Thanks @AndydeCleyre for the review

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

Successfully merging this pull request may close these issues.

Add a --verb-output launch argument
2 participants