From 1db7cda752ed90919917b6979975eae0c7ed4af3 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Wed, 2 Nov 2022 03:16:42 +0200 Subject: Adapting to 96ae225b2a179ec36fdb01eaf906fec096002a08 change, also provide usage text --- bin/ipns-resolve | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/bin/ipns-resolve b/bin/ipns-resolve index 7f7478c..6ea3799 100755 --- a/bin/ipns-resolve +++ b/bin/ipns-resolve @@ -1,3 +1,27 @@ #!/bin/bash -ipfs name resolve $1 | sed -e 's/\/ipfs\///' +PROGRAM="$(basename $0)" +usage(){ + echo "$PROGRAM - Resolves IPNS to IPFS" + echo "------------------------------------" + echo "Usage:" + echo " $PROGRAM " + echo "" + echo "Returns the resolved IPFS CIDv0" +} +logit(){ + logthis "<$PROGRAM>" "$1" "$2" +} +if [ ! -z $1 ] +then + rsld=$(ipfs name resolve $1) + if [ "$?" != 0 ] + then + logit "[ERROR]" "Failed to resolve $1" + exit 1 + fi + echo -n $rsld | sed -e 's/\/ipfs\///' + logit "[INFO]" "Resolved $1 to $rsld" +else + usage +fi -- cgit v1.2.3