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

Add a --verb-output launch argument #825

Closed
Canop opened this issue Jan 17, 2024 · 6 comments · Fixed by #834
Closed

Add a --verb-output launch argument #825

Canop opened this issue Jan 17, 2024 · 6 comments · Fixed by #834
Labels
enhancement New feature or request

Comments

@Canop
Copy link
Owner

Canop commented Jan 17, 2024

Similar to the existing --outcmd, but the file whose path is given as argument would contain what the verb decides to write.

The verb could for example be :write {file}:{line} or :write {path}.

Each time there's a write after the first one, a \n would be inserted.
There could be several lines, for example when a verb doesn't quit broot, or when the verb is called in the staging area.

Such a file would mainly be the basis for a rewritten br shell function, which would solve some escaping problems.

Related: #824

@Canop Canop added the enhancement New feature or request label Jan 17, 2024
@AndydeCleyre
Copy link

Thanks! To be clear, in your example, :write is a new internal that appends to the file specified by --verb-output?

Like a manual logger?

@Canop
Copy link
Owner Author

Canop commented Jan 18, 2024

Thanks! To be clear, in your example, :write is a new internal that appends to the file specified by --verb-output?

Yes.

@AndydeCleyre
Copy link

FWIW, I happen to be using a verb with that particular name:

  {
    invocation: write {subpath}
    external: $EDITOR {directory}/{subpath}
    leave_broot: false
  }

And I'm inclined to think of the upcoming internal as "append line"

@Canop
Copy link
Owner Author

Canop commented Jan 22, 2024

For a verb similar to yours, which is dedicated to creating new files, I use "create" with shortcut "cr".

append_line wouldn't really convey the intent, which is most often to write only one path and exit.

@Canop
Copy link
Owner Author

Canop commented Feb 14, 2024

@AndydeCleyre Did you see/test the PR ?

@AndydeCleyre
Copy link

No! Thanks for the work and the ping!

I'll test today or tonight.

Canop added a commit that referenced this issue Feb 21, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants