create=0
-while getopts :Cf:v:r:d:a:u:l:p:b:In: opt; do
+# newpackage -f pkgfile $pkgid
+while getopts :Cf:r:d:a:u:l:p:b:In: opt; do
case $opt in
f) pkgfile="$OPTARG" ;;
d) description="$OPTARG" ;;
eval "$(zpm parse -E $pkgid)"
-if [ -z "$release" ]; then
- die 'must specify full package id'
-fi
-
if [ -z "$pkgfile" ]; then
pkgfile=$ZPM_PACKAGE_FILE
fi
+# cases C = create ok, R = full package id, F = specified package file
+
+# immediate error
+# C-- 100 error, must specify something
+# --- 000 error, must specify something
+if [ -z "$release" ] && [ -z "$pkgfile" ]; then
+ die must specify package file or complete package id
+fi
+
+# --F 001 error, wouldn't know which pkgid to create, could derive from file?
+# C-F 101 error, since package wouldn't exist in file to find
+if [ -z "$release" ]; then
+ die must specify complete package id
+fi
+
+# set file from pkgid
+# CR- 110 set file from pkgid, create if needed
+# -R- 010 set file from pkgid, create in file, error if no file
if [ -z "$pkgfile" ]; then
pkgfile="$pkgid.zpm"
fi
-set -e
-
-if [ ! -e $pkgfile ]; then
+# will now be one of these
+# CRF 111 create package in file given, create file if needed
+# -RF 011 create package in file, error if file doesn't exist
+if [ ! -f "$pkgfile" ]; then
if [ $create -eq 1 ]; then
zpm init $pkgfile
else
- die "$pkgfile does not exist"
+ die $pkgfile does not exist
fi
fi
+set -e
+
if [ "$idempotent" = 1 ]; then
idempotent='or ignore'
fi