commit 97d1c6c3c1efe47d3552c4c124960409a2584646 Author: Xevion Date: Tue Oct 1 15:27:39 2024 -0500 repo init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/README.md b/README.md new file mode 100644 index 0000000..24e56bb --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# spotify-player-quickauth + +A simple CLI-based application for creating a `credentials.json` file, used by the [spotify-player][spotify-player] library, for authenticating with the Spotify API. \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..983c36d --- /dev/null +++ b/run.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Determine the platform +OS=$(uname) +ARCH=$(uname -m) + +# Set the download URL based on the platform +if [[ "$OS" == "Linux" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + PLATFORM="linux-amd64" + elif [[ "$ARCH" == "aarch64" ]]; then + PLATFORM="linux-arm64" + else + echo "Unsupported architecture: $ARCH" + exit 1 + fi +elif [[ "$OS" == "Darwin" ]]; then + if [[ "$ARCH" == "x86_64" ]]; then + PLATFORM="darwin-amd64" + elif [[ "$ARCH" == "arm64" ]]; then + PLATFORM="darwin-arm64" + else + echo "Unsupported architecture: $ARCH" + exit 1 + fi +else + echo "Unsupported OS: $OS" + exit 1 +fi + +# Fetch the latest release download URL +REPO="Xevion/spotify-player-quickauth" +API_URL="https://api.github.com/repos/$REPO/releases/latest" +DOWNLOAD_URL=$(curl -s $API_URL | grep "browser_download_url.*$PLATFORM" | cut -d '"' -f 4) + +if [[ -z "$DOWNLOAD_URL" ]]; then + echo "Failed to find a download URL for platform: $PLATFORM" + exit 1 +fi + +# # Download the executable +# EXECUTABLE="spotify-player-quickauth" +# curl -L -o $EXECUTABLE $DOWNLOAD_URL + +# # Make the executable runnable +# chmod +x $EXECUTABLE + +# # Run the executable +# ./$EXECUTABLE + +# # Delete the executable +# rm $EXECUTABLE \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8b4257a --- /dev/null +++ b/src/main.rs @@ -0,0 +1,24 @@ +use std::env; +use std::process::Command; +use std::io; + +fn main() { + let os = env::consts::OS; + let arch = env::consts::ARCH; + let username = env::var("USER").unwrap_or_else(|_| "unknown".to_string()); + let hostname = Command::new("hostname") + .output() + .map(|output| String::from_utf8_lossy(&output.stdout).trim().to_string()) + .unwrap_or_else(|_| "unknown".to_string()); + let execution_path = env::current_exe() + .map(|path| path.display().to_string()) + .unwrap_or_else(|_| "unknown".to_string()); + let working_directory = env::current_dir() + .map(|path| path.display().to_string()) + .unwrap_or_else(|_| "unknown".to_string()); + + println!( + "{}@{} ({}/{}) [{}] [{}]", + username, hostname, os, arch, working_directory, execution_path + ); +}