Skip to content
Merged
Show file tree
Hide file tree
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
49 changes: 41 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

echo "Installing Satra..."
echo "==> Installing Satra..."

ARCH=$(uname -m)
case $ARCH in
Expand All @@ -12,20 +12,53 @@ case $ARCH in
TARGET_ARCH="aarch64"
;;
*)
echo "Unsupported architecture: $ARCH"
echo "Error: Unsupported architecture: $ARCH"
exit 1
;;
esac

BIN_DIR="$HOME/.local/bin"
BIN_DIR="${CARGO_HOME:-$HOME/.local}/bin"
[ -d "$HOME/.local/bin" ] && BIN_DIR="$HOME/.local/bin"
mkdir -p "$BIN_DIR"

URL="https://github.com/TattvaOrg/Satra/releases/latest/download/satra-$TARGET_ARCH-linux"
TMP_BIN=$(mktemp)
trap 'rm -f "$TMP_BIN"' EXIT

echo "Downloading from $URL"
curl -sSL "$URL" -o "$BIN_DIR/satra"
chmod +x "$BIN_DIR/satra"
echo "==> Downloading prebuilt binary from GitHub Releases..."
if curl -sSfL "$URL" -o "$TMP_BIN" 2>/dev/null; then
# Verify file is an executable binary and not an error page
if file "$TMP_BIN" | grep -qE "ELF|executable"; then
mv "$TMP_BIN" "$BIN_DIR/satra"
chmod +x "$BIN_DIR/satra"
echo "✅ Installed successfully to $BIN_DIR/satra"
else
echo "Error: Downloaded file is not a valid binary."
exit 1
fi
else
echo "Notice: Prebuilt release binary not found at $URL"
if command -v cargo >/dev/null 2>&1; then
echo "==> Compiling and installing from source using cargo..."
cargo install --git https://github.com/TattvaOrg/Satra.git --root "${BIN_DIR%/bin}"
echo "✅ Compiled and installed successfully via cargo to $BIN_DIR/satra"
else
echo "Error: Could not download prebuilt binary and 'cargo' is not installed."
echo "Please install Rust (https://rustup.rs) or check https://github.com/TattvaOrg/Satra/releases"
exit 1
fi
fi

# PATH guidance
case ":$PATH:" in
*":$BIN_DIR:"*) ;;
*)
echo ""
echo "⚠️ Note: $BIN_DIR is not in your PATH."
echo "Add it to your shell configuration (e.g. ~/.bashrc or ~/.zshrc):"
echo " export PATH=\"\$PATH:$BIN_DIR\""
;;
esac

echo "✅ Installed successfully to $BIN_DIR/satra"
echo "Make sure $BIN_DIR is in your PATH."
echo ""
echo "Run 'satra' to start the application."
21 changes: 21 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ use ratatui::{backend::CrosstermBackend, Terminal};
use std::{io, time::Duration};

fn main() -> Result<(), io::Error> {
let args: Vec<String> = std::env::args().collect();
if args.len() > 1 {
match args[1].as_str() {
"-v" | "--version" => {
println!("satra {}", env!("CARGO_PKG_VERSION"));
return Ok(());
}
"-h" | "--help" => {
println!("Satra - A lightweight terminal-based process launcher and tracker");
println!();
println!("Usage: satra [OPTIONS]");
println!();
println!("Options:");
println!(" -h, --help Print help information");
println!(" -v, --version Print version information");
return Ok(());
}
_ => {}
}
}

enable_raw_mode()?;
let mut stdout = io::stdout();
execute!(stdout, EnterAlternateScreen)?;
Expand Down
Loading