Skip to content

Commit

Permalink
fix: --sources now handle comma separated input (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxandersen authored May 15, 2022
1 parent 81ed889 commit 07e99c8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/java/dev/jbang/cli/Alias.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class AliasAdd extends BaseAliasCommand {
@CommandLine.Mixin
DependencyInfoMixin dependencyInfoMixin;

@CommandLine.Option(names = { "-s", "--sources" }, description = "Add additional sources.")
@CommandLine.Option(names = { "-s",
"--sources" }, converter = CommaSeparatedConverter.class, description = "Add additional sources.")
List<String> sources;

@CommandLine.Option(names = { "--description",
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/jbang/cli/BaseBuildCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public abstract class BaseBuildCommand extends BaseScriptCommand {
@CommandLine.Mixin
DependencyInfoMixin dependencyInfoMixin;

@CommandLine.Option(names = { "-s", "--sources" }, description = "Add additional sources.")
@CommandLine.Option(names = { "-s",
"--sources" }, converter = CommaSeparatedConverter.class, description = "Add additional sources.")
List<String> sources;

@CommandLine.Option(names = { "-m",
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/jbang/cli/Edit.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class Edit extends BaseScriptCommand {
@CommandLine.Mixin
DependencyInfoMixin dependencyInfoMixin;

@CommandLine.Option(names = { "-s", "--sources" }, description = "Add additional sources.")
@CommandLine.Option(names = { "-s",
"--sources" }, converter = CommaSeparatedConverter.class, description = "Add additional sources.")
List<String> sources;

@CommandLine.Option(names = {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/jbang/cli/ExportMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class ExportMixin {
}, description = "Force export, i.e. overwrite exported file if already exists")
boolean force;

@CommandLine.Option(names = { "-s", "--sources" }, description = "Add additional sources.")
@CommandLine.Option(names = { "-s",
"--sources" }, converter = CommaSeparatedConverter.class, description = "Add additional sources.")
List<String> sources;
@CommandLine.Parameters(paramLabel = "scriptOrFile", index = "0", description = "A file or URL to a Java code file", arity = "1")
String scriptOrFile;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/jbang/cli/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ abstract class BaseInfoCommand extends BaseScriptCommand {
@CommandLine.Mixin
DependencyInfoMixin dependencyInfoMixin;

@CommandLine.Option(names = { "-s", "--sources" }, description = "Add additional sources.")
@CommandLine.Option(names = { "-s",
"--sources" }, converter = CommaSeparatedConverter.class, description = "Add additional sources.")
List<String> sources;

static class ResourceFile {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/dev/jbang/source/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ static Stream<String> extractDependencies(String line) {
if (args.containsKey("ext")) {
gav = gav + "@" + args.get("ext");
}
return Stream.of(gav);
if (!gav.isEmpty()) { // protects when @Grab might be inside a string (like jbang source)
return Stream.of(gav);
} else {
return Stream.empty();
}
} else {
matcher = DEPS_ANNOT_SINGLE.matcher(line);
if (matcher.find()) {
Expand Down

0 comments on commit 07e99c8

Please sign in to comment.