A library for handling DID identifiers used in Bluesky AT Protocol
at 0.0.2 32 lines 570 B view raw
1#!/usr/bin/env ruby 2# frozen_string_literal: true 3 4require "bundler/setup" 5require "didkit" 6 7begin 8 query = ARGV[0].to_s 9 10 if query =~ /^did\:/ 11 did = DID.new(query) 12 elsif query =~ /^@[\w\-]+(\.[\w\-]+)+$/ 13 did = DID.resolve_handle(query) 14 else 15 puts "Usage: #{$PROGRAM_NAME} <@handle> | <did:...>" 16 exit 1 17 end 18 19 if did.nil? 20 puts "Couldn't resolve handle #{query}" 21 return 22 end 23 24 doc = did.get_document 25 26 puts 27 puts "PDS: #{doc.pds_endpoint}" 28 puts 29 puts JSON.pretty_generate(doc.json) 30rescue StandardError => e 31 puts "Error: #{e}" 32end