#!/usr/bin/env python

import sys
from pmtiles.reader import read

if len(sys.argv) <= 1:
    print("Usage: pmtiles-show PMTILES_FILE")
    exit(1)

with read(sys.argv[1]) as reader:
    if len(sys.argv) == 2:
        print('spec version: ',reader.version)
        print('metadata:')
        for k, v in reader.metadata.items():
            print(k,'=',v)
        print('root entries:', reader.root_entries)
    else:
        z = int(sys.argv[2])
        x = int(sys.argv[3])
        y = int(sys.argv[4])
        print(reader.get(z,x,y))
