#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from builtins import str as futureenc
from optparse import OptionParser
from arcrestsplite import ArcGIS

def do(url,dbname,verbose):
    arcgis = ArcGIS(url)
    if arcgis.isarcgisrest:
        arcgis.discover() 
        arcgis.createdbcatalog(dbname)
        if verbose:
            print "url\tname\tquerable\txmin\tymin\txman\tyman\tsrd\tdescription\ttypel\tgeometrytype"
        if verbose:
            for layer in arcgis.layers:
                url = layer['url']
                name =  futureenc(layer['name'])
                querable = layer['querable']
                xmin = layer['properties']['extent']['xmin']
                ymin = layer['properties']['extent']['ymin']
                xmax = layer['properties']['extent']['xmax']
                ymax = layer['properties']['extent']['ymax']
                srid = layer['properties']['extent']['spatialReference']['wkid']
                description =  futureenc(layer['properties']['description'])
                typel = layer['properties']['type']
                geometrytype = layer['properties']['geometryType'].replace('esriGeometry','')
                print "%s\t%s\t%\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" % (url,name,querable,xmin,ymin,xmax,ymax,srid,description,typel,geometrytype)
    else:
        print "%s isn't a valid ArcGIS Rest service"
        
def main():
    verbose = False
    usage = """
	%prog [options] url
	
	this script extract the information about all the layers present in a ArcGIS Rest API service
	url => url of the ArcGIS Rest API service
    """
    parser = OptionParser(usage)
    parser.add_option("-v","--verbose",action="store_true",dest="verbose",help="verbose output")
    parser.add_option("-d","--dbname",action="store",dest="dbname",help="sqlite file to store the data")
    (options,args) = parser.parse_args()
    if len(args) == 0:
        parser.print_help()
    else:
        url = args[0]
        dbname = options.dbname
        verbose = options.verbose
	if dbname is None:
		verbose = True
        do(url,dbname,verbose)
        
if __name__ == "__main__":
    main()

@@ -1469,19 +1469,34 @@
 ptions%5D 
-url
+source destination
 %0A%09%0A%09this
@@ -1586,19 +1586,22 @@
 ervice%0A%09
-url
+source
  =%3E url 
@@ -1631,16 +1631,87 @@
 service%0A
+      destionation =%3E the path of the sqlite file where store the data%0A
     %22%22%22%0A
@@ -1842,113 +1842,22 @@
 put%22
-)%0A    parser.add_option(%22-d%22,%22--dbname%22,action=%22store%22,dest=%22dbname%22,help=%22sqlite file to store the data%22
+,default=False
 )%0A  
@@ -1916,12 +1916,12 @@
 gs) 
-== 0
+!= 2
 :%0A  
@@ -1964,19 +1964,22 @@
         
-url
+source
  = args%5B
@@ -1994,30 +1994,29 @@
    d
-bname = options.dbname
+estination =  args%5B1%5D
 %0A   
@@ -2050,66 +2050,37 @@
 ose%0A
-%09if dbname is None:%0A%09%09verbose = True%0A
+  
       
-  
 do(
-url,dbname
+source,destination
 ,ver
@@ -2093,16 +2093,20 @@
         
+    
 %0Aif __na

correct cli bug