Rewrite: move sway_tree.rs

This commit is contained in:
Akemi Izuko 2023-12-23 20:14:05 -07:00
parent b0a2631193
commit 4c584522a2
Signed by: akemi
GPG key ID: 8DE0764E1809E9FC
4 changed files with 21 additions and 16 deletions

View file

@ -1,9 +0,0 @@
#!/usr/bin/env -S awk -f
# Translate the unix-timestamps in bash history to dates. Requires gnu `date`
{
if ($0 ~ /^#[0-9]+$/)
system("date -d @" substr($0, 2));
else
print " "$0
}

View file

@ -10,6 +10,10 @@ authors = ["Akemi Izuko"]
name = "prettify_bash_history" name = "prettify_bash_history"
path = "src/prettify_bash_history.rs" path = "src/prettify_bash_history.rs"
[[bin]]
name = "sway_tree"
path = "src/sway_tree.rs"
[dependencies] [dependencies]
clap = { version = "4", features = ["derive"] } clap = { version = "4", features = ["derive"] }
chrono = "0.4" chrono = "0.4"

View file

@ -417,9 +417,11 @@ russy_checks() {
check_for_russy_bins() { check_for_russy_bins() {
local -i return_code=0 local -i return_code=0
local -a bin_names local -a bin_names
bin_names=($(awk '/name =/ { split($0, a, "\""); print a[2] }' ~/.configs_pointer/bin/rewritten_in_rust/Cargo.toml))
while IFS='' read -r line; do
bin_names+=("$line")
done < <(awk '/name =/ { split($0, a, "\""); print a[2] }' ~/.configs_pointer/bin/rewritten_in_rust/Cargo.toml)
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
for (( i = 1; i < "${#bin_names[@]}"; i++ )); do for (( i = 1; i < "${#bin_names[@]}"; i++ )); do
@ -443,15 +445,22 @@ check_for_russy_bins() {
russy_build() { russy_build() {
if command -v cargo &>/dev/null; then if command -v cargo &>/dev/null; then
if cargo build --release --manifest-path="$HOME/.configs_pointer/bin/rewritten_in_rust/Cargo.toml"; then if cargo build --release --manifest-path="$HOME/.configs_pointer/bin/rewritten_in_rust/Cargo.toml"; then
local -a bin_names
while IFS='' read -r line; do
bin_names+=("$line")
done < <(awk '/name =/ { split($0, a, "\""); print a[2] }' ~/.configs_pointer/bin/rewritten_in_rust/Cargo.toml)
local name local name
for exe in $(fd -d1 -tx . ~/.configs_pointer/bin/rewritten_in_rust/target/release); do for (( i = 1; i < "${#bin_names[@]}"; i++ )); do
name="$(basename "$exe")" name="$(basename "${bin_names[i]}")"
( (
cd ~/.configs_pointer/bin || return 1 cd ~/.configs_pointer/bin || return 1
if ! [[ -e "$name" ]]; then if ! [[ -e "$name" ]]; then
ln -s "./rewritten_in_rust/target/release/$name" "./$name" ln -s "./rewritten_in_rust/target/release/$name" "./$name"
echo "$name" >> ~/.configs_pointer/bin/.gitignore
elif ! [[ -L "$name" ]]; then elif ! [[ -L "$name" ]]; then
printf 'ERR: Failed to link rust binary \`%s\`\n' "$name" printf 'ERR: Failed to link rust binary \`%s\`\n' "$name"
printf '\tRemove the conflicting file\n' printf '\tRemove the conflicting file\n'
@ -470,8 +479,11 @@ russy_build() {
fi fi
} }
if [[ "$1" == 'build' ]]; then
russy_build || exit 1
fi
if [[ "$1" == 'status' && "$(uname -s)" == 'Linux' ]]; then if [[ "$(uname -s)" == 'Linux' ]] && [[ "$1" == 'status' || "$1" == 'build' ]]; then
configs_pointer_is_setup || exit 1 configs_pointer_is_setup || exit 1
swayland_checks swayland_checks
@ -485,8 +497,6 @@ if [[ "$1" == 'status' && "$(uname -s)" == 'Linux' ]]; then
git_checks git_checks
ssh_checks ssh_checks
russy_checks russy_checks
elif [[ "$1" == 'build' ]]; then
russy_build
else else
print_help print_help
fi fi