magic-wormhole / magic-wormhole.rs

Rust implementation of Magic Wormhole, with new features and enhancements
European Union Public License 1.2
722 stars 78 forks source link

Add option to pipe code to an external process #134

Open rpls opened 2 years ago

rpls commented 2 years ago

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 commented 2 years ago

Some questions:

piegamesde commented 2 years ago

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[bot] commented 2 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@166d434). Click here to learn what that means. The diff coverage is 0.00%.

:exclamation: Current head e9bed58 differs from pull request most recent head f5eb431. Consider uploading reports for the commit f5eb431 to get more accurate results Impacted file tree graph

@@            Coverage Diff            @@
##             master     #134   +/-   ##
=========================================
  Coverage          ?   63.23%           
=========================================
  Files             ?       12           
  Lines             ?     1934           
  Branches          ?        0           
=========================================
  Hits              ?     1223           
  Misses            ?      711           
  Partials          ?        0           
Impacted Files Coverage Δ
src/bin/main.rs 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 166d434...f5eb431. Read the comment docs.

piegamesde commented 2 years ago

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

rpls commented 2 years ago

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 commented 2 years ago

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

zeri42 commented 2 years ago
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 commented 2 years ago

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?