import click

try:
    from tqdm import tqdm
except ImportError:
    def tqdm(x):
        return x

from cloudside import asos, hydra


@click.group()
def main():
    pass


@main.command()
@click.argument('station')
@click.argument('startdate')
@click.argument('enddate')
@click.argument('email')
@click.option('--folder')
@click.option('--force', is_flag=True)
def get_asos(station, startdate, enddate, email, folder, force):
    folder = '.' or folder
    return asos.get_data(station, startdate, enddate, email, folder=folder,
                         force_download=force, pbar_fxn=tqdm)


@main.command()
@click.argument('station')
@click.option('--folder')
@click.option('--force', is_flag=True)
def get_hydra(station, folder, force):
    folder = '.' or folder
    return hydra.get_data(station, folder=folder, force_download=force)

@@ -195,33 +195,33 @@
 ck.argument(
-'
+%22
 station
-'
+%22
 )%0A@click.arg
@@ -226,17 +226,17 @@
 rgument(
-'
+%22
 startdat
@@ -232,25 +232,25 @@
 t(%22startdate
-'
+%22
 )%0A@click.arg
@@ -259,17 +259,17 @@
 ent(
-'
+%22
 enddate
-'
+%22
 )%0A@c
@@ -286,15 +286,15 @@
 ent(
-'
+%22
 email
-'
+%22
 )%0A@c
@@ -301,33 +301,33 @@
 lick.option(
-'
+%22
 --folder
 ')%0A@click.op
@@ -306,33 +306,33 @@
 option(%22--folder
-'
+%22
 )%0A@click.option(
@@ -327,33 +327,33 @@
 lick.option(
-'
+%22
 --force
-'
+%22
 , is_flag=Tr
@@ -348,32 +348,59 @@
 , is_flag=True)%0A
+@click.option(%22--outfile%22)%0A
 def get_asos(sta
@@ -437,32 +437,41 @@
 l, folder, force
+, outfile
 ):%0A    folder = 
@@ -462,35 +462,35 @@
 ):%0A    folder = 
-'.'
+%22.%22
  or folder%0A    r
@@ -488,22 +488,20 @@
 der%0A    
-return
+df =
  asos.ge
@@ -507,24 +507,41 @@
 et_data(
-station,
+%0A        station,%0A       
  startda
@@ -535,32 +535,40 @@
       startdate,
+%0A       
  enddate, email,
@@ -556,31 +556,47 @@
     enddate,
- email,
+%0A        email,%0A       
  folder=fold
@@ -599,33 +599,16 @@
 folder,%0A
-                 
         
@@ -628,16 +628,24 @@
 d=force,
+%0A       
  pbar_fx
@@ -650,16 +650,83 @@
 fxn=tqdm
+,%0A    )%0A    if outfile:%0A        df.to_csv(outfile, encoding=%22utf-8%22
 )%0A%0A%0A@mai
@@ -757,17 +757,17 @@
 ent(
-'
+%22
 station
-'
+%22
 )%0A@c
@@ -782,17 +782,17 @@
 ion(
-'
+%22
 --folder
 ')%0A@
@@ -787,17 +787,17 @@
 --folder
-'
+%22
 )%0A@click
@@ -808,17 +808,17 @@
 ion(
-'
+%22
 --force
-'
+%22
 , is
@@ -829,16 +829,43 @@
 g=True)%0A
+@click.option(%22--outfile%22)%0A
 def get_
@@ -892,16 +892,25 @@
 r, force
+, outfile
 ):%0A    f
@@ -921,11 +921,11 @@
 r = 
-'.'
+%22.%22
  or 
@@ -935,22 +935,20 @@
 der%0A    
-return
+df =
  hydra.g
@@ -1001,8 +1001,69 @@
 =force)%0A
+    if outfile:%0A        df.to_csv(outfile, encoding=%22utf-8%22)%0A

add CLI options for outfile