diff --git a/Container.shc b/Container.shc index e780cdb..43908c4 100644 --- a/Container.shc +++ b/Container.shc @@ -1,6 +1,6 @@ # # DockerBashOOP - Implementation of BashOOP for Docker. -# Copyright (C) 2021 Ad5001 +# Copyright (C) 2022 Ad5001 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by @@ -203,6 +203,12 @@ Container.logs() { $this.applyToAll logs $@ } +# Starts all stopped containers +# Signature: ([string[] arguments]) -> string +Container.start() { + $this.applyToAll start $@ +} + # Executes a command to all the containers assigned to the instance. # Signature: ([string[] options] ) -> void|string Container.exec() { diff --git a/Docker.shn b/Docker.shn index 23faf1e..2c2fa32 100644 --- a/Docker.shn +++ b/Docker.shn @@ -1,6 +1,6 @@ # # DockerBashOOP - Implementation of BashOOP for Docker. -# Copyright (C) 2021 Ad5001 +# Copyright (C) 2022 Ad5001 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by diff --git a/README.md b/README.md new file mode 100644 index 0000000..8bdfe98 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# DockerBashOOP +--- + +Small implementation of Docker for BashOOP. + +### Documentation + +You can generate the documentation using my [bash DocGenerator](https://git.ad5001.eu/Ad5001/DocGenerator). + +### How to use + +Import the library: +```bash +. $OOP_ROOT/oop.sh + +importNamespace "path/to/Docker.shn" +``` + +**Note**: The guides require to know how to use [BashOOP Objects](https://git.ad5001.eu/Ad5001/BashOOP). + +You can store several docker containers in a single Docker.Container object. +The way it's constructed is using keywords that acts as filter for all current Docker containers (both running and stopped). + +For example: +Find all stopped containers based on the image ubuntu:14:04 : +```bash +Docker.Container c with_image "ubuntu:14.04" stopped +``` +**Note**: If you're executing this as a non root user, you may be prompted for your account password in order to access docker data. + +A list of all filters can be found in the documentation. + +You can see if any object was found using `$c.found`, and the count of containers found using `$c.count`. + +You can then access their properties like you would any other object: +```bash +# Their container name +$c.name + +# Their container id +$c.id + +# Their base image +$c.image + +# Amongst others... +# And assign them: +names="$($c.name)" +``` + +**Note**: When several containers are matched, the value for each container will be put on a new line. diff --git a/Utils.shc b/Utils.shc index 3532307..b330d54 100644 --- a/Utils.shc +++ b/Utils.shc @@ -1,6 +1,6 @@ # # DockerBashOOP - Implementation of BashOOP for Docker. -# Copyright (C) 2021 Ad5001 +# Copyright (C) 2022 Ad5001 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by diff --git a/libraries/oop b/libraries/oop index 7663b31..82038ce 160000 --- a/libraries/oop +++ b/libraries/oop @@ -1 +1 @@ -Subproject commit 7663b31788a1c03ebec380a3b71652bd29c05de3 +Subproject commit 82038ce35d4c695bcd627f461479e219277c2c84