Repository: goldmann/docker-squash

Issue:
--output-path description is confused
```
  --output-path OUTPUT_PATH
                        Path where the image should be stored after squashing.
                        If not provided, image will be loaded into Docker
                        daemon
```
It sounds like "If you specify the output path, squashed image won't load back to docker daemon"
But in fact, It still load the squashed image into docker daemon, store as file is just an addition behavior, but not a replacement.

Discussion:

Patch:
diff --git a/README.rst b/README.rst
index c016dae..bc8b29e 100644
--- a/README.rst
+++ b/README.rst
@@ -67,16 +67,16 @@ Usage
                             Number of layers to squash or ID of the layer (or image ID or image name) to squash from.
                             In case the provided value is an integer, specified number of layers will be squashed.
                             Every layer in the image will be squashed if the parameter is not provided.
-      -t TAG, --tag TAG     Specify the tag to be used for the new image. If not
-                            specified no tag will be applied
+      -t TAG, --tag TAG     Specify the tag to be used for the new image. If not specified no tag will be applied
       -m MESSAGE, --message MESSAGE
                             Specify a commit message (comment) for the new image.
       -c, --cleanup         Remove source image from Docker after squashing
       --tmp-dir TMP_DIR     Temporary directory to be created and used
       --output-path OUTPUT_PATH
-                            Path where the image should be stored after squashing.
-                            If not provided, image will be loaded into Docker
-                            daemon
+                            Path where the image may be stored after squashing.
+      --load-image [LOAD_IMAGE]
+                            Whether to load the image into Docker daemon after squashing
+                            Default: true
 
 Note that environment variables may be set as documented in `here <docs/environment_variables.adoc>`_.
 
diff --git a/docker_squash/cli.py b/docker_squash/cli.py
index 1a9c31c..73e981d 100644
--- a/docker_squash/cli.py
+++ b/docker_squash/cli.py
@@ -23,6 +23,17 @@ class SingleLevelFilter(logging.Filter):
 
 
 class MyParser(argparse.ArgumentParser):
+    # noinspection PyMethodMayBeStatic
+    def str2bool(self, v: str) -> bool:
+        if isinstance(v, bool):
+            return v
+        if v.lower() in ("yes", "true", "t", "y", "1"):
+            return True
+        elif v.lower() in ("no", "false", "f", "n", "0"):
+            return False
+        else:
+            raise argparse.ArgumentTypeError("Boolean value expected.")
+
     def error(self, message):
         self.print_help()
         sys.stderr.write("\nError: %s\n" % message)
@@ -92,7 +103,15 @@ class CLI(object):
         )
         parser.add_argument(
             "--output-path",
-            help="Path where the image should be stored after squashing. If not provided, image will be loaded into Docker daemon",
+            help="Path where the image may be stored after squashing.",
+        )
+        parser.add_argument(
+            "--load-image",
+            type=parser.str2bool,
+            const=True,
+            nargs="?",
+            default=True,
+            help="Whether to load the image into Docker daemon after squashing",
         )
 
         args = parser.parse_args()
@@ -103,7 +122,6 @@ class CLI(object):
             self.log.setLevel(logging.INFO)
 
         self.log.debug("Running version %s", version)
-
         try:
             squash.Squash(
                 log=self.log,
@@ -112,6 +130,7 @@ class CLI(object):
                 tag=args.tag,
                 comment=args.message,
                 output_path=args.output_path,
+                load_image=args.load_image,
                 tmp_dir=args.tmp_dir,
                 development=args.development,
                 cleanup=args.cleanup,
diff --git a/docker_squash/squash.py b/docker_squash/squash.py
index d470ea5..802a910 100644
--- a/docker_squash/squash.py
+++ b/docker_squash/squash.py
@@ -46,7 +46,7 @@ class Squash(object):
         docker_version = self.docker.version()
         self.log.info(
             "docker-squash version %s, Docker %s, API %s..."
-            % (version, docker_version["GitCommit"], docker_version["ApiVersion"])
+            % (version, docker_version["Version"], docker_version["ApiVersion"])
         )
 
         if self.image is None:


Test patch:
diff --git a/tests/test_unit_squash.py b/tests/test_unit_squash.py
index e2e024d..b9d55ea 100644
--- a/tests/test_unit_squash.py
+++ b/tests/test_unit_squash.py
@@ -12,7 +12,7 @@ class TestSquash(unittest.TestCase):
         self.log = mock.Mock()
         self.docker_client = mock.Mock()
         self.docker_client.version.return_value = {
-            "GitCommit": "commit/9.9.9",
+            "Version": "20.10.23",
             "ApiVersion": "9.99",
         }