diff --git a/src/main/java/io/seqera/tower/cli/commands/LaunchCmd.java b/src/main/java/io/seqera/tower/cli/commands/LaunchCmd.java index e3812a03..29c18a2d 100644 --- a/src/main/java/io/seqera/tower/cli/commands/LaunchCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/LaunchCmd.java @@ -80,7 +80,7 @@ public class LaunchCmd extends AbstractRootCmd { @CommandLine.Mixin public WorkspaceOptionalOptions workspace; - @Option(names = {"--params-file"}, description = "Pipeline parameters in either JSON or YML format.") + @Option(names = {"--params-file"}, description = "Pipeline parameters in either JSON or YML format. Use '-' to read from stdin.") Path paramsFile; @Option(names = {"-c", "--compute-env"}, description = "Compute environment name [default: primary compute environment].") @@ -351,13 +351,13 @@ private AdvancedOptions adv() { public static class AdvancedOptions { - @Option(names = {"--config"}, description = "Additional Nextflow config file.") + @Option(names = {"--config"}, description = "Additional Nextflow config file. Use '-' to read from stdin.") public Path config; - @Option(names = {"--pre-run"}, description = "Bash script that is executed in the same environment where Nextflow runs just before the pipeline is launched.") + @Option(names = {"--pre-run"}, description = "Bash script that is executed in the same environment where Nextflow runs just before the pipeline is launched. Use '-' to read from stdin.") public Path preRunScript; - @Option(names = {"--post-run"}, description = "Bash script that is executed in the same environment where Nextflow runs immediately after the pipeline completion.") + @Option(names = {"--post-run"}, description = "Bash script that is executed in the same environment where Nextflow runs immediately after the pipeline completion. Use '-' to read from stdin.") public Path postRunScript; @Option(names = {"--pull-latest"}, description = "Enable Nextflow to pull the latest repository version before running the pipeline.") diff --git a/src/main/java/io/seqera/tower/cli/commands/pipelines/LaunchOptions.java b/src/main/java/io/seqera/tower/cli/commands/pipelines/LaunchOptions.java index 796a7cc3..c1dc898b 100644 --- a/src/main/java/io/seqera/tower/cli/commands/pipelines/LaunchOptions.java +++ b/src/main/java/io/seqera/tower/cli/commands/pipelines/LaunchOptions.java @@ -33,19 +33,19 @@ public class LaunchOptions { @Option(names = {"-p", "--profile"}, split = ",", description = "Comma-separated list of one or more configuration profile names you want to use for this pipeline execution.") public List profile; - @Option(names = {"--params-file"}, description = "Pipeline parameters in either JSON or YML format.") + @Option(names = {"--params-file"}, description = "Pipeline parameters in either JSON or YML format. Use '-' to read from stdin.") public Path paramsFile; @Option(names = {"--revision"}, description = "A valid repository commit Id, tag or branch name.") public String revision; - @Option(names = {"--config"}, description = "Path to a Nextflow config file. Values defined here override the same values in the pipeline repository config file, and all configuration values specified in Platform pipeline or compute environment Nextflow config fields are ignored.") + @Option(names = {"--config"}, description = "Path to a Nextflow config file. Values defined here override the same values in the pipeline repository config file, and all configuration values specified in Platform pipeline or compute environment Nextflow config fields are ignored. Use '-' to read from stdin.") public Path config; - @Option(names = {"--pre-run"}, description = "Bash script that is executed in the same environment where Nextflow runs just before the pipeline is launched.") + @Option(names = {"--pre-run"}, description = "Bash script that is executed in the same environment where Nextflow runs just before the pipeline is launched. Use '-' to read from stdin.") public Path preRunScript; - @Option(names = {"--post-run"}, description = "Bash script that is executed in the same environment where Nextflow runs immediately after the pipeline completion.") + @Option(names = {"--post-run"}, description = "Bash script that is executed in the same environment where Nextflow runs immediately after the pipeline completion. Use '-' to read from stdin.") public Path postRunScript; @Option(names = {"--pull-latest"}, description = "Enable Nextflow to pull the latest repository version before running the pipeline.") diff --git a/src/main/java/io/seqera/tower/cli/utils/FilesHelper.java b/src/main/java/io/seqera/tower/cli/utils/FilesHelper.java index e9d5d7fa..ddfb5ad7 100644 --- a/src/main/java/io/seqera/tower/cli/utils/FilesHelper.java +++ b/src/main/java/io/seqera/tower/cli/utils/FilesHelper.java @@ -17,10 +17,12 @@ package io.seqera.tower.cli.utils; +import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStreamReader; import java.nio.file.Files; import java.nio.file.Path; @@ -33,9 +35,26 @@ public static String readString(Path path) throws IOException { if (path == null) { return null; } + + // Check if path represents stdin (conventionally "-") + if (path.toString().equals("-")) { + return readFromStdin(); + } + return Files.readString(path); } + private static String readFromStdin() throws IOException { + StringBuilder content = new StringBuilder(); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) { + String line; + while ((line = reader.readLine()) != null) { + content.append(line).append(System.lineSeparator()); + } + } + return content.toString(); + } + public static void saveString(String fileName, String text) { try { BufferedWriter writer;