#!/bin/bash
if [ "$#" -ne 2 ]; then echo "Usage: postpress <source_file> <target_name>" exit 1 fi
SRC="$1" TGT_NAME="$2"
if [[ "$TGT_NAME" == "/" ]]; then echo "Error: Target name must be a simple filename, no paths." exit 1 fi
if [[ "$TGT_NAME" != *.md ]]; then TGT_NAME="${TGT_NAME}.md" fi
if [ ! -f "$SRC" ]; then echo "Error: Source file '$SRC' not found." exit 1 fi
TGT_PATH="/n/press/$TGT_NAME"
if cp "$SRC" "$TGT_PATH"; then echo "Published: $SRC -> $TGT_PATH" else echo "Error: Failed to copy $SRC to $TGT_PATH" exit 1 fi