-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --one-shot mode for copy command
The default mode to copy data requires to assemble bytes in order to follow the simple protocol, which is not easy for the simple command line use case. "--one-shot" is added to make richclip work like traditional clipboard utilities.
- Loading branch information
Showing
8 changed files
with
190 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# CHANGES | ||
|
||
Next Release | ||
|
||
- Add `--one-shot` mode to allow copying data as it is from stdin. | ||
|
||
v0.2.1 | ||
|
||
- The first public release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
mod recv; | ||
mod source_data; | ||
|
||
pub use recv::receive_data; | ||
pub use recv::receive_data_bulk; | ||
pub use recv::receive_data_oneshot; | ||
#[allow(unused_imports)] | ||
pub use recv::PROTOCAL_VER; | ||
pub use source_data::SourceData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bats | ||
|
||
# Tests with own copy & paste. Ideally this would run on all platforms | ||
|
||
bats_require_minimum_version 1.5.0 | ||
|
||
ROOT_DIR=$(realpath "$BATS_TEST_DIRNAME/../../..") | ||
RICHCLIP="$ROOT_DIR/target/debug/richclip" | ||
|
||
XVFB_PID="" | ||
|
||
setup_file() { | ||
unset WAYLAND_DISPLAY | ||
export DISPLAY=":42" | ||
# Start a headless X server for testing | ||
Xvfb $DISPLAY 3>&- & | ||
XVFB_PID=$! | ||
sleep 1 | ||
run -0 cargo build | ||
} | ||
|
||
teardown_file() { | ||
if [ -n "$XVFB_PID" ]; then | ||
kill "$XVFB_PID" | ||
fi | ||
} | ||
|
||
teardown() { | ||
killall -w richclip > /dev/null || echo "" | ||
} | ||
|
||
@test "one-shot mode: no '--type'" { | ||
# one-shot no type | ||
echo "TestDaTA" | $RICHCLIP copy --one-shot | ||
|
||
run -0 "$RICHCLIP" paste -l | ||
[ "${lines[0]}" = "TARGETS" ] | ||
[ "${lines[1]}" = "text/plain" ] | ||
[ "${lines[2]}" = "text/plain;charset=utf-8" ] | ||
[ "${lines[3]}" = "TEXT" ] | ||
[ "${lines[4]}" = "STRING" ] | ||
[ "${lines[5]}" = "UTF8_STRING" ] | ||
|
||
run -0 "$RICHCLIP" paste | ||
[ "$output" = "TestDaTA" ] | ||
} | ||
|
||
@test "one-shot mode: with '--type'" { | ||
# one-shot, one type | ||
echo "TestDaTA" | $RICHCLIP copy --type TypE | ||
|
||
run -0 "$RICHCLIP" paste -l | ||
[ "${lines[0]}" = "TARGETS" ] | ||
[ "${lines[1]}" = "TypE" ] | ||
|
||
run -0 "$RICHCLIP" paste -t TypE | ||
[ "$output" = "TestDaTA" ] | ||
|
||
# one-shot, multi types | ||
echo "TestDaTA" | $RICHCLIP copy --type TypE --type Faker | ||
run -0 "$RICHCLIP" paste -l | ||
[ "${lines[0]}" = "TARGETS" ] | ||
[ "${lines[1]}" = "TypE" ] | ||
[ "${lines[2]}" = "Faker" ] | ||
|
||
run -0 "$RICHCLIP" paste -t Faker | ||
[ "$output" = "TestDaTA" ] | ||
} |