#!/usr/bin/env python
import argcomplete
import argparse
import imp
import os

pathname = os.path.dirname(os.path.abspath(__file__))
DSET = os.path.join(os.path.abspath(pathname), 'dset')
dset = imp.load_source('dset', DSET)

parser = argparse.ArgumentParser(description='Stop a docker container. Without argument, all containers are stopped.')
parser.add_argument("container", help="container name", nargs='*')
argcomplete.autocomplete(parser)
args = parser.parse_args()

if not bool(args.container):
        print "Stopping all containers..."
        dset.call("docker-compose {} stop".format(dset.docker_compose_params()))

for container in args.container:
        dset.call("docker stop {}_{}_1".format(dset.compose_project(), container))
