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 option to pipe code to an external process #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rpls
Copy link

@rpls rpls commented Oct 29, 2021

This adds a command line flag --command for the send{,-many} commands that allows a user to specify a shell command to which the code-word is piped. This could, for example, enable a user to pipe the command to xclip to achieve #123. This is more versatile as this would allow a user to script some things, and probably a lot simpler than supporting clipboards in general.

It's just a crude first try, I'm not a rust programmer. But it works for me.

@rpls
Copy link
Author

rpls commented Oct 29, 2021

Some questions:

  • Should the command line flag be renamed?
  • Should this use an asynchronous version of std::process (adds external dependency async-process)?

Copy link
Member

@piegamesde piegamesde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. It's a worth while feature to have right now, but be aware that clipboard support might make it obsolete one day.


Should the command line flag be renamed?

Yes, see my review comment.

Should this use an asynchronous version of std::process (adds external dependency async-process)?

To be honest, not sure. I think we can always change it to async if the need ever comes up.

src/bin/main.rs Outdated Show resolved Hide resolved
src/bin/main.rs Outdated Show resolved Hide resolved
src/bin/main.rs Outdated Show resolved Hide resolved
src/bin/main.rs Outdated Show resolved Hide resolved
src/bin/main.rs Outdated Show resolved Hide resolved
src/bin/main.rs Outdated Show resolved Hide resolved
@piegamesde
Copy link
Member

I just got an idea for a different approach to the problem that I'd like to discuss: how about having a command that generates a code? Example usage:

code=$(wormhole generate-code)
wormhole send --code=$code
wormhole recieve $code
code=$(wormhole generate-code)
xclip $code
wormhole send --code=$code

@codecov

This comment has been minimized.

@piegamesde
Copy link
Member

Since when do we have a code coverage bot?! :D

@rpls
Copy link
Author

rpls commented Oct 30, 2021

I just got an idea for a different approach to the problem that I'd like to discuss: how about having a command that generates a code? Example usage:

code=$(wormhole generate-code)
wormhole send --code=$code
wormhole recieve $code
code=$(wormhole generate-code)
xclip $code
wormhole send --code=$code

That would work too I guess. And users could probably have a shell alias or function in their profile to have this in one go.

@rpls rpls marked this pull request as ready for review October 31, 2021 15:46
@rpls
Copy link
Author

rpls commented Oct 31, 2021

I worked in all the suggestions, but the windows support is untested.

@zeri42
Copy link

zeri42 commented Nov 1, 2021

generate-code)
wormhole send --code=$code
wormhole recieve $code

if you do that you can use anything as a code that starts with a number like this:

code=$((RANDOM%1024))-$(head -c 16 /dev/urandom | xxd -ps)
xclip $code
wormhole send --code=$code

@piegamesde piegamesde mentioned this pull request Mar 5, 2022
@piegamesde
Copy link
Member

I just made #141. Please give it a try. Do we still need your proposed solution for some use cases? Are those use cases worth supporting?

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.

None yet

3 participants