-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: actpub
action: blob
revision:
path_from: self
revision_from: refs/heads/master:
path_to:
revision_to:

git.thebackupbox.net

actpub

git://git.thebackupbox.net/actpub

blob of:

actpub

/ self

refs/heads/master:/self
 #!/usr/bin/env bash

 SELFDIR=~/.config/self

 if [ "$1" = "" -o "$1" = "-h" -o "$1" = "--help" ];then
   printf 'self <-l|--list>\n' >&2
   printf 'self <-i|--init>\n' >&2
   printf 'self <-g|--get> [property]\n' >&2
   printf 'self <-s|--set> [property] <<< "value"\n' >&2
   exit 0
 fi

 if [ "$1" = "-i" -o "$1" = "--init" ];then
   if mkdir -p "${SELFDIR}";then
     printf 'self directory has been made at %s\n' "${SELFDIR}" >&2
     exit 0
   else
     printf 'self directory creation failed somehow.\n' >&2
     exit 1
   fi
 fi

 if [ ! -e "${SELFDIR}" ];then
   printf 'self directory (%s) does not exist.  use self --init\n' "${SELFDIR}" >&2
   exit 1
 fi

 case "$1" in
 -l|--list)
   find "${SELFDIR}" -type f -print0 | xargs -n1 -r0 basename
   ;;
 -g|--get)
   shift
   file="${SELFDIR}/$1"
   if [ ! "$1" ];then
     printf 'missing argument: property\n' >&2
     exit 1
   fi
   if [ ! -e "$file" ];then
     printf 'self property "%s" not found\n' "$1" >&2
     exit 1
   fi
   cat "$file"
   ;;
 -s|--set)
   shift
   if [ ! "$1" ];then
     printf 'missing argument: property\n' >&2
     exit 1
   fi
   file="${SELFDIR}/$1"
   cat > "$file"
   ;;
 *)
   exit 1
   ;;
 esac

-- Response ended

-- Page fetched on Sun Jun 2 17:03:18 2024