Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/io/seqera/tower/cli/commands/LaunchCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -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].")
Expand Down Expand Up @@ -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.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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.")
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/io/seqera/tower/cli/utils/FilesHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down