Make usage alphabetical

This commit is contained in:
Ben Firshman 2013-12-31 17:05:20 +00:00
parent e5065bed16
commit 770e78fdce

View File

@ -71,14 +71,14 @@ class TopLevelCommand(Command):
--version Print version and exit --version Print version and exit
Commands: Commands:
up Create and start containers kill Kill containers
logs View output from containers logs View output from containers
ps List containers ps List containers
rm Remove stopped containers
run Run a one-off command run Run a one-off command
start Start services start Start services
stop Stop services stop Stop services
kill Kill containers up Create and start containers
rm Remove stopped containers
""" """
def docopt_options(self): def docopt_options(self):
@ -86,6 +86,24 @@ class TopLevelCommand(Command):
options['version'] = "fig %s" % __version__ options['version'] = "fig %s" % __version__
return options return options
def kill(self, options):
"""
Kill containers.
Usage: kill [SERVICE...]
"""
self.project.kill(service_names=options['SERVICE'])
def logs(self, options):
"""
View output from containers.
Usage: logs [SERVICE...]
"""
containers = self.project.containers(service_names=options['SERVICE'], stopped=False)
print "Attaching to", list_containers(containers)
LogPrinter(containers, attach_params={'logs': True}).run()
def ps(self, options): def ps(self, options):
""" """
List containers. List containers.
@ -117,6 +135,22 @@ class TopLevelCommand(Command):
]) ])
print Formatter().table(headers, rows) print Formatter().table(headers, rows)
def rm(self, options):
"""
Remove stopped containers
Usage: rm [SERVICE...]
"""
all_containers = self.project.containers(service_names=options['SERVICE'], stopped=True)
stopped_containers = [c for c in all_containers if not c.is_running]
if len(stopped_containers) > 0:
print "Going to remove", list_containers(stopped_containers)
if yesno("Are you sure? [yN] ", default=False):
self.project.remove_stopped(service_names=options['SERVICE'])
else:
print "No stopped containers"
def run(self, options): def run(self, options):
""" """
Run a one-off command. Run a one-off command.
@ -146,6 +180,22 @@ class TopLevelCommand(Command):
service.start_container(container, ports=None) service.start_container(container, ports=None)
c.run() c.run()
def start(self, options):
"""
Start existing containers.
Usage: start [SERVICE...]
"""
self.project.start(service_names=options['SERVICE'])
def stop(self, options):
"""
Stop running containers.
Usage: stop [SERVICE...]
"""
self.project.stop(service_names=options['SERVICE'])
def up(self, options): def up(self, options):
""" """
Create and start containers. Create and start containers.
@ -172,56 +222,6 @@ class TopLevelCommand(Command):
finally: finally:
self.project.kill(service_names=options['SERVICE']) self.project.kill(service_names=options['SERVICE'])
def start(self, options):
"""
Start existing containers.
Usage: start [SERVICE...]
"""
self.project.start(service_names=options['SERVICE'])
def stop(self, options):
"""
Stop running containers.
Usage: stop [SERVICE...]
"""
self.project.stop(service_names=options['SERVICE'])
def kill(self, options):
"""
Kill containers.
Usage: kill [SERVICE...]
"""
self.project.kill(service_names=options['SERVICE'])
def rm(self, options):
"""
Remove stopped containers
Usage: rm [SERVICE...]
"""
all_containers = self.project.containers(service_names=options['SERVICE'], stopped=True)
stopped_containers = [c for c in all_containers if not c.is_running]
if len(stopped_containers) > 0:
print "Going to remove", list_containers(stopped_containers)
if yesno("Are you sure? [yN] ", default=False):
self.project.remove_stopped(service_names=options['SERVICE'])
else:
print "No stopped containers"
def logs(self, options):
"""
View output from containers.
Usage: logs [SERVICE...]
"""
containers = self.project.containers(service_names=options['SERVICE'], stopped=False)
print "Attaching to", list_containers(containers)
LogPrinter(containers, attach_params={'logs': True}).run()
def _attach_to_container(self, container_id, interactive, logs=False, stream=True, raw=False): def _attach_to_container(self, container_id, interactive, logs=False, stream=True, raw=False):
stdio = self.client.attach_socket( stdio = self.client.attach_socket(
container_id, container_id,