#!/usr/bin/env python3
#------------------------------------------------------------------------------
#    The MB-system:  mbm_docker   27 June 2023
#
#    Copyright (c) 2023-2024 by
#    David W. Caress (caress@mbari.org)
#      Monterey Bay Aquarium Research Institute
#      Moss Landing, California, USA
#    Dale N. Chayes 
#      Center for Coastal and Ocean Mapping
#      University of New Hampshire
#      Durham, New Hampshire, USA
#    Christian dos Santos Ferreira
#      MARUM
#      University of Bremen
#      Bremen Germany
#      
#    MB-System was created by Caress and Chayes in 1992 at the
#      Lamont-Doherty Earth Observatory
#      Columbia University
#      Palisades, NY 10964
#
#    See README.md file for copying and redistribution conditions.
#------------------------------------------------------------------------------
# Start Docker container with MB-System installed
#
# David W. Caress
# 3 April 2024
#------------------------------------------------------------------------------

#import sys, getopt, os
#import glob, subprocess

import getopt

shortOpts = "hbi:dg:"
longOpts = ["help", "display", "input=", "grid=", "mission="]

def usage():
  pname, sname = os.path.split(sys.argv[0])
  sys.stderr.write("usage: % s %s < path > \n" % (sname, str(longOpts)))
  print( """
  -h --help                  Print this message
  -d --docker=image          Docker image name [mbari/mbsystem:latest]
  -u --user=username         Username [mbuser]
  -w --workdir=path          Working directory [$PWD]
  -x --x11server=ip:0.       Set X11 server, typically ip address with ":0" appended
  """ )
  sys.exit()

def main (args, opts={}):

  # Handle command line options
  docker = "mbsys-debian"
  username = "mbuser"
  workdir = $PWD
  x11server = ""
  x11serverset = False
  for o, a in opts:
    if o in ("-h", "--help"):
      usage()
    elif o in ("-d", "--docker"):
      docker = a
    elif o in ("-u", "--user"):
      username = a
    elif o in ("-x", "--x11server"):
      x11server = a
      x11serverset = True
    else:
      assert False, "unhandled option: "+o+" "+a



