mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-25 23:35:55 +02:00
dsv/dsv: record source URL in dsv-* file; new option -u to show it
This adds a second line to the dsv-* files, containing the source URL. dsv -u <word> shows the URL. Compatibility with older versions of dsv: - "dsv -u" will fail with an error if running on an old data sheet database, while the rest of dsv works as before - to update the database, run the usual "dsv setup ..." (most dsv-using projects have a "make dsv" target for this) - older version of dsv will not be able to display data sheets or paths if run with an updated database
This commit is contained in:
parent
24160ddd57
commit
676c6a2715
23
dsv/dsv
23
dsv/dsv
@ -30,12 +30,13 @@ DSV_DIR=.dsv
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "usage: $0 [-p] <component>" 2>&1
|
||||
echo "usage: $0 [-p|-u] <component>" 2>&1
|
||||
echo " $0 help" 2>&1
|
||||
echo " $0 [ls]" 2>&1
|
||||
echo " $0 setup <info-file> ..." 2>&1
|
||||
echo 2>&1
|
||||
echo " -p show the path instead of displaying the file " 2>&1
|
||||
echo " -u show source URL instead of displaying the file " 2>&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
@ -78,7 +79,7 @@ flush()
|
||||
fi
|
||||
eval for n in $name $alias\; do \
|
||||
'nm=`echo "$n" | sed "s/%/%25/g;s|/|%2F|g"`;' \
|
||||
echo '"$ds"' '>$DSV_DIR/dsv-$nm'\; \
|
||||
\{ echo '"$ds"'\; echo '"$url"'\; \} '>$DSV_DIR/dsv-$nm'\; \
|
||||
done
|
||||
name=
|
||||
alias=
|
||||
@ -157,7 +158,18 @@ search()
|
||||
if [ -d $DSV_DIR ]; then
|
||||
name=`echo "$1" | sed 's/%/%25/g;s|/|%2F|g'`
|
||||
if [ -r "$DSV_DIR/dsv-$name" ]; then
|
||||
file=`cat "$DSV_DIR/dsv-$name"`
|
||||
if $show_url; then
|
||||
url=`sed 1d "$DSV_DIR/dsv-$name"`
|
||||
if [ "$url" ]; then
|
||||
echo "$url"
|
||||
exit
|
||||
else
|
||||
echo "$DSV_DIR/dsv-$name" \
|
||||
"does not contain an URL - please regenerate" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
file=`sed 1q "$DSV_DIR/dsv-$name"`
|
||||
if [ ! -r "$DSV_DIR/$file" ]; then
|
||||
echo "$1 -> $file: does not exist" 2>&1
|
||||
exit 1
|
||||
@ -179,10 +191,15 @@ search()
|
||||
|
||||
|
||||
path=false
|
||||
show_url=false
|
||||
if [ "$1" = -p ]; then
|
||||
path=true
|
||||
shift
|
||||
fi
|
||||
if [ "$1" = -u ]; then
|
||||
show_url=true
|
||||
shift
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
help|-*) usage;;
|
||||
|
Loading…
Reference in New Issue
Block a user