aboutsummaryrefslogtreecommitdiff
path: root/bin/ipns-resolve
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ipns-resolve')
-rwxr-xr-xbin/ipns-resolve26
1 files changed, 25 insertions, 1 deletions
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 <IPNS>"
+ 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