Compare commits
No commits in common. "e14010eb5302ca3f6076342d95e91915c9861b02" and "b97c09828dd6294bb357ab401da4708d255bc016" have entirely different histories.
e14010eb53
...
b97c09828d
4 changed files with 8 additions and 57 deletions
|
@ -1,4 +1,4 @@
|
||||||
steps:
|
pipeline:
|
||||||
test:
|
test:
|
||||||
image: bats/bats
|
image: bats/bats
|
||||||
commands:
|
commands:
|
||||||
|
|
|
@ -38,7 +38,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- Always download from newest emoji list url
|
- Always download from newest emoji list url
|
||||||
- Pass selection to custom typing tools through stdin
|
- Pass selection to custom typing tools through stdin
|
||||||
- Pass info messages to stderr to avoid passing to picker tools
|
|
||||||
|
|
||||||
<!-- ### Security -->
|
<!-- ### Security -->
|
||||||
|
|
||||||
|
|
19
bemoji
19
bemoji
|
@ -59,11 +59,6 @@ version() {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
msg() {
|
|
||||||
# Outputs a message to stderr, to be used for info, warning and error messages.
|
|
||||||
printf "%s\n" "$1" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
parse_cli() {
|
parse_cli() {
|
||||||
while getopts cD:ef:hnpP:tv-: arg "$@"; do
|
while getopts cD:ef:hnpP:tv-: arg "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
|
@ -135,7 +130,7 @@ prepare_db() {
|
||||||
if [ -n "$BEMOJI_DOWNLOAD_LIST" ]; then
|
if [ -n "$BEMOJI_DOWNLOAD_LIST" ]; then
|
||||||
# Populate default lists
|
# Populate default lists
|
||||||
if echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'none'; then
|
if echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'none'; then
|
||||||
msg "Not downloading a default emoji list."
|
printf "Not downloading a default emoji list.\n"
|
||||||
return
|
return
|
||||||
elif echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'all'; then
|
elif echo "$BEMOJI_DOWNLOAD_LIST" | grep -q -e 'all'; then
|
||||||
dl_default_emoji
|
dl_default_emoji
|
||||||
|
@ -163,19 +158,19 @@ dl_default_emoji() {
|
||||||
local emojis
|
local emojis
|
||||||
emojis=$(curl -sSL "https://unicode.org/Public/emoji/latest/emoji-test.txt")
|
emojis=$(curl -sSL "https://unicode.org/Public/emoji/latest/emoji-test.txt")
|
||||||
printf "%s" "$emojis" | sed -ne 's/^.*; fully-qualified.*# \(\S*\) \S* \(.*$\)/\1 \2/gp' >"$bm_db_location/emojis.txt"
|
printf "%s" "$emojis" | sed -ne 's/^.*; fully-qualified.*# \(\S*\) \S* \(.*$\)/\1 \2/gp' >"$bm_db_location/emojis.txt"
|
||||||
msg "Downloaded default emoji set."
|
printf "Downloaded default emoji set.\n"
|
||||||
}
|
}
|
||||||
dl_math_symbols() {
|
dl_math_symbols() {
|
||||||
curl -sSL "https://unicode.org/Public/math/latest/MathClassEx-15.txt" |
|
curl -sSL "https://unicode.org/Public/math/latest/MathClassEx-15.txt" |
|
||||||
grep -ve '^#' | cut -d';' -f3,7 | sed -e 's/;/ /' >"$bm_db_location/math.txt"
|
grep -ve '^#' | cut -d';' -f3,7 | sed -e 's/;/ /' >"$bm_db_location/math.txt"
|
||||||
msg "Downloaded math symbols set."
|
printf "Downloaded math symbols set.\n"
|
||||||
}
|
}
|
||||||
dl_nerd_symbols() {
|
dl_nerd_symbols() {
|
||||||
local nerd all
|
local nerd all
|
||||||
nerd=$(curl -sSL "https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/css/nerd-fonts-generated.css")
|
nerd=$(curl -sSL "https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/css/nerd-fonts-generated.css")
|
||||||
all+=$(printf "%s" "$nerd" | sed -ne '/\.nf-/p' -e '/\s*[^_]content:/p' | sed -e 'N;s/^\.nf-\(.*\):before.* content: \"\\\(.*\)\";/\\U\2 \1/')
|
all+=$(printf "%s" "$nerd" | sed -ne '/\.nf-/p' -e '/\s*[^_]content:/p' | sed -e 'N;s/^\.nf-\(.*\):before.* content: \"\\\(.*\)\";/\\U\2 \1/')
|
||||||
echo -e "$all" > "$bm_db_location/nerdfont.txt"
|
echo -e "$all" > "$bm_db_location/nerdfont.txt"
|
||||||
msg "Downloaded nerdfont symbols set."
|
printf "Downloaded nerdfont symbols set.\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
gather_emojis() {
|
gather_emojis() {
|
||||||
|
@ -236,7 +231,7 @@ _clipper() {
|
||||||
elif [ -n "$DISPLAY" ] && command -v xsel >/dev/null 2>&1; then
|
elif [ -n "$DISPLAY" ] && command -v xsel >/dev/null 2>&1; then
|
||||||
xsel -b
|
xsel -b
|
||||||
else
|
else
|
||||||
msg "No suitable clipboard tool found."
|
printf "No suitable clipboard tool found."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -255,7 +250,7 @@ _typer() {
|
||||||
elif [ -n "$DISPLAY" ] && command -v xdotool >/dev/null 2>&1; then
|
elif [ -n "$DISPLAY" ] && command -v xdotool >/dev/null 2>&1; then
|
||||||
xdotool type --delay 30 "$totype"
|
xdotool type --delay 30 "$totype"
|
||||||
else
|
else
|
||||||
msg "No suitable typing tool found."
|
printf "No suitable typing tool found."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -275,7 +270,7 @@ _picker() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
msg "No suitable picker tool found."
|
printf "No suitable picker tool found." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
setup_file() {
|
|
||||||
# make bemoji executable from anywhere relative to current testfile
|
|
||||||
TEST_DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
PATH="$TEST_DIR/..:$PATH"
|
|
||||||
}
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
load 'test_helper/bats-support/load'
|
|
||||||
load 'test_helper/bats-assert/load'
|
|
||||||
|
|
||||||
# set up small default set of test emoji for each test
|
|
||||||
export BEMOJI_DB_LOCATION="$BATS_TEST_TMPDIR/database"
|
|
||||||
export BEMOJI_HISTORY_LOCATION="$BATS_TEST_TMPDIR/history"
|
|
||||||
mkdir -p "$BEMOJI_DB_LOCATION" "$BEMOJI_HISTORY_LOCATION"
|
|
||||||
cat "$BATS_TEST_DIRNAME/resources/test_emoji.txt" > "$BEMOJI_DB_LOCATION/emoji.txt"
|
|
||||||
|
|
||||||
# these tests require stdout to be separated from stderr
|
|
||||||
# such run flags were only introduced in recent bats version
|
|
||||||
bats_require_minimum_version 1.5.0
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "Prints clipper error to stderr" {
|
|
||||||
BEMOJI_PICKER_CMD="echo hi" run --separate-stderr bemoji 3>&-
|
|
||||||
assert_output ""
|
|
||||||
output="$stderr"
|
|
||||||
assert_output "No suitable clipboard tool found."
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "Prints picker error to stderr" {
|
|
||||||
run --separate-stderr bemoji 3>&-
|
|
||||||
assert_output ""
|
|
||||||
output="$stderr"
|
|
||||||
assert_output "No suitable picker tool found."
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "Prints typer error to stderr" {
|
|
||||||
BEMOJI_PICKER_CMD="echo hi" run --separate-stderr bemoji -t 3>&-
|
|
||||||
assert_output ""
|
|
||||||
output="$stderr"
|
|
||||||
assert_output "No suitable typing tool found."
|
|
||||||
}
|
|
Loading…
Reference in a new issue