# -*- coding: utf-8 -*-
import click
import os
import argparse
import atws
from atws.helpers import create_atvar_module
from atws.monkeypatch.duckpunch import BLACKLISTED_TYPES, get_api_types

@click.command()
def main(args=None):
    parser = argparse.ArgumentParser(description='test')
    parser.add_argument('target_path')
    parser.add_argument('--username', 
                        default=os.environ.get('AUTOTASK_API_USERNAME', None))
    parser.add_argument('--password', 
                        default=os.environ.get('AUTOTASK_API_PASSWORD', None))
    parser.add_argument('--url', 
                        default=os.environ.get('AUTOTASK_API_URL', None))
    parser.add_argument('--entities',
                        help='Space delimited entity types for inclusion',
                        nargs='+', 
                        default=[]
                        )
    
    args = parser.parse_args()
    if not args.username or not args.password:
        exit(parser.print_usage())
    
    at = atws.connect(url=args.url,
                      username=args.username,
                      password=args.password)
    
    if args.entities:
        entities = args.entities
    else:
        entities = get_api_types(at.client, BLACKLISTED_TYPES)
    
    create_atvar_module(at, entities, args.target_path)


if __name__ == "__main__":
    main()
@@ -28,21 +28,18 @@
 ort 
-click
+os
 %0Aimport 
 os%0Ai
@@ -38,49 +38,47 @@
 ort 
-os%0Aimport argparse%0Aimport atws
+click%0Afrom wrapper import connect
 %0Afrom 
-atws.
 help
@@ -113,21 +113,16 @@
 le%0Afrom 
-atws.
 monkeypa
@@ -197,101 +197,15 @@
 d()%0A
-def main(args=None):%0A    parser = argparse.ArgumentParser(description='test')%0A    parser.add_
+@click.
 argu
@@ -224,39 +224,29 @@
 _path')%0A
-    parser.add_argument
+@click.option
 ('--user
@@ -249,34 +249,24 @@
 username', %0A
-          
             
@@ -324,33 +324,69 @@
 one)
-)
+, 
 %0A    
-parser.add_argument
+          help='your Autotask username')%0A@click.option
 ('--
@@ -395,28 +395,17 @@
 ssword',
- %0A          
+%0A
         
@@ -467,54 +467,79 @@
 one)
-)
+, 
 %0A    
-parser.add_argument('--url', %0A          
+          help='your Autotask password')%0A@click.option('--url',%0A
     
@@ -600,33 +600,88 @@
 one)
-)
+, 
 %0A    
-parser.add_argument
+          help='your Autotask webservices URL (wsdl file)')%0A@click.option
 ('--
@@ -693,32 +693,53 @@
 ies',%0A          
+    default=list(), %0A
               he
@@ -789,224 +789,67 @@
 ion'
-,%0A                        nargs='+', %0A                        default=%5B%5D%0A                        )%0A    %0A    args = parser.parse_args()%0A    if not args.username or not args.password:%0A        exit(parser.print_usage())
+)%0Adef main(target_path, username, password, url, entities):
 %0A   
@@ -863,13 +863,8 @@
 t = 
-atws.
 conn
@@ -871,21 +871,16 @@
 ect(url=
-args.
 url,%0A   
@@ -907,21 +907,16 @@
 sername=
-args.
 username
@@ -948,21 +948,16 @@
 assword=
-args.
 password
@@ -974,64 +974,20 @@
  if 
-args.entities:%0A        entities = args.entities%0A    else
+not entities
 :%0A  
@@ -1094,13 +1094,8 @@
 es, 
-args.
 targ

convert to click