summaryrefslogtreecommitdiff
path: root/share/keyringer/preferences
blob: 2819b50878e70ecd955aa4099d99b1ee10de636e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#
# Manipulate preferences.
#

# Load functions
LIB="`dirname $0`/../../lib/keyringer/functions"
source "$LIB" || exit 1

COMMAND="$2"

if [ -z "$COMMAND" ]; then
  echo "Usage: keyringer <keyring> preferences <command> [arguments]"
  echo "Available commands:"
  echo "	ls"
  echo "	edit"
  echo "	add"
  exit 1
fi

# Create options file if old repository
if [ ! -e "$PREFERENCES" ]; then
  echo "Creating preferences file..."
  touch "$PREFERENCES"
fi

if [ "$COMMAND" == "ls" ]; then
  cat "$PREFERENCES"
elif [ "$COMMAND" == "edit" ]; then
  "$EDITOR" "$PREFERENCES"
elif [ "$COMMAND" == "add" ]; then
  shift 2
  [[ -n $* ]] && echo $* >> "$PREFERENCES"
else
  printf "%s: No such command %s\n" "$BASENAME" "$COMMAND"
  exit 1
fi