#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
everest-status
--------------

'''

import argparse

if __name__ == '__main__':

  parser = argparse.ArgumentParser(prog = 'estats', add_help = True)
  parser.add_argument("season", nargs = '?', type = str, default = None, help = 'The season to check')
  parser.add_argument("model", nargs = '?', type = str, default = None, help = 'The everest model to check')
  parser.add_argument("-i", "--inject", action = 'store_true', help = 'Check injection runs?')
  parser.add_argument("-m", "--mission", type = str, default = 'k2', help = 'Mission to analyze')
  parser.add_argument("-s", "--short", action = 'store_true', help = 'Short cadence?')
  args = parser.parse_args()
  
  # Get the mission
  from everest import missions
  Status = getattr(missions, args.mission).Status
  
  # Get the season number
  if args.season is not None:
    if '.' in args.season:
      season = float(args.season)
    else:
      season = int(args.season)
  else:
    season = None
  
  # Cadence
  if args.short:
    cadence = 'sc'
  else:
    cadence = 'lc'
  
  # Injection run?
  if args.inject:
    injection = True
  else:
    injection = False
  
  # Call the function
  if season is not None:
    if args.model is not None:
      Status(season = season, model = args.model, injection = injection, cadence = cadence)
    else:
      Status(season = season, injection = injection, cadence = cadence)
  else:
    if args.model is not None:
      Status(model = args.model, injection = injection, cadence = cadence)
    else:
      Status(injection = injection, cadence = cadence)