From 6e6a17dc82c9194fbb8986588aeb56f2702243e6 Mon Sep 17 00:00:00 2001
From: Enderson Maia <endersonmaia@gmail.com>
Date: Wed, 21 Aug 2024 14:36:17 -0300
Subject: [PATCH] feat(cli): add hidden `run --dry-run` argument

adds a `--dry-run` argument to `cartesi run` command so it's possible to
see the .yaml file used by docker compose to start the local infratructure
---
 .changeset/chatty-toes-relate.md |  5 +++++
 apps/cli/src/commands/run.ts     | 14 ++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 .changeset/chatty-toes-relate.md

diff --git a/.changeset/chatty-toes-relate.md b/.changeset/chatty-toes-relate.md
new file mode 100644
index 00000000..2ede6e42
--- /dev/null
+++ b/.changeset/chatty-toes-relate.md
@@ -0,0 +1,5 @@
+---
+"@cartesi/cli": patch
+---
+
+adds --dry-run to run command
diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts
index f3364147..db7c6105 100644
--- a/apps/cli/src/commands/run.ts
+++ b/apps/cli/src/commands/run.ts
@@ -54,6 +54,11 @@ export default class Run extends BaseCommand<typeof Run> {
             description: "port to listen for incoming connections",
             default: 8080,
         }),
+        "dry-run": Flags.boolean({
+            description: "show the docker compose configuration",
+            default: false,
+            hidden: true,
+        }),
     };
 
     public async run(): Promise<void> {
@@ -169,6 +174,15 @@ export default class Run extends BaseCommand<typeof Run> {
         process.on("SIGINT", () => {});
 
         try {
+            if (flags["dry-run"]) {
+                // show the docker compose configuration
+                await execa("docker", [...compose_args, "config"], {
+                    env,
+                    stdio: "inherit",
+                });
+                return;
+            }
+
             // run compose environment
             await execa("docker", [...compose_args, "up", ...up_args], {
                 env,