Commit bc0cc04
Changed files (2)
addmods.bat
@@ -0,0 +1,71 @@
+@echo off
+setlocal EnableDelayedExpansion
+
+if "%~1"=="-h" goto :ShowHelp
+if "%~1"=="--help" goto :ShowHelp
+if "%~1"=="" (
+ echo Error: Missing platform argument.
+ goto :ShowHelp
+)
+set "PLATFORM_ARG=%~1"
+set "PLATFORM_CMD="
+set "PLATFORM_NAME="
+if /I "%PLATFORM_ARG%"=="mr" (
+ set "PLATFORM_CMD=mr"
+ set "PLATFORM_NAME=Modrinth"
+) else if /I "%PLATFORM_ARG%"=="cf" (
+ set "PLATFORM_CMD=cf"
+ set "PLATFORM_NAME=CurseForge"
+) else (
+ echo Error: Invalid platform '%PLATFORM_ARG%'. Allowed: 'mr', 'cf'.
+ exit /b 1
+)
+
+where packwiz >nul 2>&1
+if %errorlevel% neq 0 (
+ echo Error: 'packwiz' command not found in PATH.
+ exit /b 1
+)
+echo Reading clipboard for: %PLATFORM_NAME% (%PLATFORM_CMD%)...
+echo ----------------------------------------
+for /f "usebackq tokens=*" %%L in (`powershell -NoProfile -Command "Get-Clipboard | Where-Object { $_ -match '\S' }"`) do (
+ set "LINE=%%L"
+
+ set "IS_COMMENT=0"
+ if "!LINE:~0,1!"=="#" set "IS_COMMENT=1"
+
+ if "!IS_COMMENT!"=="0" (
+ <nul set /p="Processing: !LINE! ... "
+
+ packwiz %PLATFORM_CMD% add "!LINE!" >nul
+
+ if !errorlevel! equ 0 (
+ echo OK
+ ) else (
+ echo FAILED
+ echo [^^!] Error occurred while adding above link. 1>&2
+ )
+ )
+)
+echo ----------------------------------------
+echo Done.
+exit /b 0
+
+:ShowHelp
+echo Usage: %~nx0 ^<platform^> [OPTIONS]
+echo.
+echo Description:
+echo Read lines from the system clipboard and add them to packwiz.
+echo Uses PowerShell to access the Windows clipboard.
+echo.
+echo Arguments:
+echo platform The platform to add mods from.
+echo Must be either 'mr' (Modrinth) or 'cf' (CurseForge).
+echo.
+echo Options:
+echo -h, --help Show this help message and exit.
+echo.
+echo Examples:
+echo %~nx0 mr REM Add mods from clipboard to Modrinth
+echo %~nx0 cf REM Add mods from clipboard to CurseForge
+exit /b 0
addmods.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+show_help() {
+ echo "Usage: $(basename "$0") <platform> [OPTIONS]"
+ echo ""
+ echo "Description:"
+ echo " Read lines from the system clipboard and add them to packwiz."
+ echo " Can detect macOS, Wayland, and X11 environments automatically."
+ echo ""
+ echo "Arguments:"
+ echo " platform The platform to add mods from."
+ echo " Must be either 'mr' (Modrinth) or 'cf' (CurseForge)."
+ echo ""
+ echo "Options:"
+ echo " -h, --help Show this help message and exit."
+ echo ""
+ echo "Examples:"
+ echo " $(basename "$0") mr # Add mods from clipboard to Modrinth"
+ echo " $(basename "$0") cf # Add mods from clipboard to CurseForge"
+}
+
+get_clipboard() {
+ if [ "$(uname)" = "Darwin" ]; then
+ # macOS
+ pbpaste
+ elif [ -n "$WAYLAND_DISPLAY" ] && command -v wl-paste >/dev/null 2>&1; then
+ # Linux Wayland
+ wl-paste
+ elif [ -n "$DISPLAY" ]; then
+ # Linux X11
+ if command -v xclip >/dev/null 2>&1; then
+ xclip -selection clipboard -o
+ elif command -v xsel >/dev/null 2>&1; then
+ xsel --clipboard --output
+ else
+ echo "Error: X11 environment detected but 'xclip' or 'xsel' not found." >&2
+ exit 1
+ fi
+ else
+ echo "Error: Could not detect a supported clipboard provider." >&2
+ echo " (Checked for: pbpaste, wl-paste, xclip, xsel)" >&2
+ exit 1
+ fi
+}
+
+if [ $# -eq 0 ]; then
+ echo "Error: Missing platform argument." >&2
+ show_help
+ exit 1
+fi
+PLATFORM_CMD=""
+PLATFORM_NAME=""
+case "$1" in
+ -h|--help)
+ show_help
+ exit 0
+ ;;
+ mr)
+ PLATFORM_CMD="mr"
+ PLATFORM_NAME="Modrinth"
+ ;;
+ cf)
+ PLATFORM_CMD="cf"
+ PLATFORM_NAME="CurseForge"
+ ;;
+ *)
+ echo "Error: Invalid platform '$1'. Allowed: 'mr', 'cf'." >&2
+ exit 1
+ ;;
+esac
+if ! command -v packwiz >/dev/null 2>&1; then
+ echo "Error: 'packwiz' command not found in PATH." >&2
+ exit 1
+fi
+
+
+echo "Reading clipboard for: $PLATFORM_NAME ($PLATFORM_CMD)..."
+echo "----------------------------------------"
+get_clipboard | sed '/^[[:space:]]*$/d' | while IFS= read -r line; do
+ case "$line" in \#*) continue ;; esac
+ printf "Processing: %s ... " "$line"
+ if packwiz "$PLATFORM_CMD" add "$line" >/dev/null; then
+ echo "OK"
+ else
+ echo "FAILED"
+ echo " [!] Error occurred while adding above link." >&2
+ fi
+done
+echo "----------------------------------------"
+echo "Done."