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

chore(script): fix assistant.sh script #1777

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 72 additions & 14 deletions assistant.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,20 +1,78 @@
#!/bin/sh

MODE=$(gum choose "Build Extensions" "Build UI")
FLAGS=$(gum choose " --profile=rapid" " --profile=dev" " --profile=release")
# Check if 'gum' is available in the system
if ! command -v gum &> /dev/null; then
echo "'gum' is not found. Attempting to install it using Homebrew..."

# Check if Homebrew is installed
if ! command -v brew &> /dev/null; then
echo "Homebrew is not installed. Please install Homebrew (https://brew.sh/) and try again."
exit 1
fi

case $MODE in
"Build Extensions")
echo "cargo build --all ${FLAGS}"
if [ $FLAGS != " --profile=release" ]
then
echo "cp -r target/debug/*.dylib ~/.uplink/extensions"
else
echo "cp -r target/release/*.dylib ~/.uplink/extensions"
fi
# Install 'gum' using Homebrew
brew install gum

# Check if the installation was successful
if ! command -v gum &> /dev/null; then
echo "Failed to install 'gum'. Please install it manually and try again."
exit 1
fi
fi

echo "Select an action:"
echo "1. Build Extensions"
echo "2. Build UI"
echo "3. Help"
echo "4. Run Clippy"
echo "5. Run Fmt"
echo "6. Auto-fix Clippy"
echo "7. Auto-fix Fmt"

read -p "Enter your choice (1/2/3/4/5/6/7): " choice

case $choice in
1)
FLAGS=$(echo " --profile=rapid" " --profile=dev" " --profile=release" | xargs -n1 | gum choose)
echo "cargo build --all ${FLAGS}"
if [ "$FLAGS" != " --profile=release" ]; then
echo "cp -r target/debug/*.dylib ~/.uplink/extensions"
else
echo "cp -r target/release/*.dylib ~/.uplink/extensions"
fi
;;
2)
echo "Building UI..."
cargo run
;;
3)
echo "Usage: $0"
echo "Options:"
echo " 1. Build Extensions: Build extensions for the specified profile"
echo " 2. Build UI: Build the user interface"
echo " 3. Help: Show this help message"
echo " 4. Run Clippy: Run the Clippy linter"
echo " 5. Run Fmt: Run the Rust formatter in check mode"
echo " 6. Auto-fix Clippy: Automatically fix Clippy warnings"
echo " 7. Auto-fix Fmt: Automatically format the code using Rust fmt"
;;
4)
echo "Running Clippy..."
cargo clippy
;;
5)
echo "Running Fmt..."
cargo fmt --check
;;
6)
echo "Auto-fixing Clippy warnings..."
cargo clippy --fix
;;
7)
echo "Auto-fixing Fmt..."
cargo fmt
;;
*)
# TODO: help here
echo "sorry, this isn't built yet."
echo "Invalid choice. Please select a valid option."
;;
esac
esac
Loading