From 1febc6dc512dd74118422c758b61185f83330146 Mon Sep 17 00:00:00 2001 From: Greg Gibeling Date: Sat, 7 Mar 2026 09:41:51 -0800 Subject: [PATCH] G2-1885 Generalize command invocation & integrate metadata --- .../com/g2forge/project/plan/create/Create.java | 13 +++++++------ .../java/com/g2forge/project/plan/Download.java | 5 ++--- .../main/java/com/g2forge/project/plan/Sprints.java | 6 +++--- .../java/com/g2forge/project/report/Billing.java | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pj-create/src/main/java/com/g2forge/project/plan/create/Create.java b/pj-create/src/main/java/com/g2forge/project/plan/create/Create.java index 6494a1a..52780a8 100644 --- a/pj-create/src/main/java/com/g2forge/project/plan/create/Create.java +++ b/pj-create/src/main/java/com/g2forge/project/plan/create/Create.java @@ -4,13 +4,13 @@ import java.io.InputStream; import java.io.PrintStream; import java.net.URISyntaxException; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.regex.Pattern; @@ -311,8 +311,9 @@ protected Map implementChanges(Server server, Changes changes) t try { final Issue actualIssue = issueClient.getIssue(created.getKey()).get(); final Iterable transitions = issueClient.getTransitions(actualIssue).get(); - final Transition transition = StreamSupport.stream(transitions.spliterator(), false).filter(t -> Objects.equal(t.getName(), transitionName)).findFirst().orElse(null); - issueClient.transition(actualIssue, new TransitionInput(transition.getId())).get(); + final Optional transition = StreamSupport.stream(transitions.spliterator(), false).filter(t -> Objects.equal(t.getName(), transitionName)).findFirst(); + if (transition.isEmpty()) throw new IllegalArgumentException(String.format("There was no transition named %1$s in Jira, please check that you're using the name of the transition, rather than the desired end state, and update your issue creation config", transitionName)); + issueClient.transition(actualIssue, new TransitionInput(transition.get().getId())).get(); } catch (ExecutionException e) { throwables.add(e); continue; @@ -336,11 +337,11 @@ protected Map implementChanges(Server server, Changes changes) t } @Override - public IExit invoke(CommandInvocation invocation) throws Throwable { + public IExit invoke(CommandInvocation invocation) throws Throwable { if (invocation.getArguments().size() < 1 || invocation.getArguments().size() > 2) throw new IllegalArgumentException("You must specify one or two inputs the optional path to server and the path fo the config!"); final boolean hasServer = invocation.getArguments().size() > 1; - final IDataSource server = hasServer ? new PathDataSource(Paths.get(invocation.getArguments().get(0))) : null; - final IDataSource config = new PathDataSource(Paths.get(invocation.getArguments().get(hasServer ? 1 : 0))); + final IDataSource server = hasServer ? new PathDataSource(invocation.getArgumentsAsArguments().get(0).getPath()) : null; + final IDataSource config = new PathDataSource(invocation.getArgumentsAsArguments().get(hasServer ? 1 : 0).getPath()); createIssues(server, config).entrySet().forEach(entry -> System.out.println(String.format("%1$s %2$s", entry.getValue(), entry.getKey()))); return IStandardCommand.SUCCESS; } diff --git a/pj-plan/src/main/java/com/g2forge/project/plan/Download.java b/pj-plan/src/main/java/com/g2forge/project/plan/Download.java index dc7ea53..2f2b2bb 100644 --- a/pj-plan/src/main/java/com/g2forge/project/plan/Download.java +++ b/pj-plan/src/main/java/com/g2forge/project/plan/Download.java @@ -5,7 +5,6 @@ import java.io.PrintStream; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -52,10 +51,10 @@ public static Path withBase(Path base, Path path) { } @Override - public IExit invoke(CommandInvocation invocation) throws Throwable { + public IExit invoke(CommandInvocation invocation) throws Throwable { HLog.getLogControl().setLogLevel(Level.INFO); if (invocation.getArguments().size() != 1) throw new IllegalArgumentException(); - final Path inputPath = Paths.get(invocation.getArguments().get(0)); + final Path inputPath = invocation.getArgumentsAsArguments().get(0).getPath(); final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); final Input input = mapper.readValue(inputPath.toFile(), Input.class); diff --git a/pj-plan/src/main/java/com/g2forge/project/plan/Sprints.java b/pj-plan/src/main/java/com/g2forge/project/plan/Sprints.java index a33ddf3..69074d7 100644 --- a/pj-plan/src/main/java/com/g2forge/project/plan/Sprints.java +++ b/pj-plan/src/main/java/com/g2forge/project/plan/Sprints.java @@ -19,10 +19,10 @@ public static void main(String[] args) throws Throwable { } @Override - public IExit invoke(CommandInvocation invocation) throws Throwable { + public IExit invoke(CommandInvocation invocation) throws Throwable { if (invocation.getArguments().size() != 2) throw new IllegalArgumentException(); - final long initialSprintId = Long.parseLong(invocation.getArguments().get(0)); - final int sprintDuration = Integer.parseInt(invocation.getArguments().get(1)); + final long initialSprintId = Long.parseLong(invocation.getArgumentsAsArguments().get(0).getString()); + final int sprintDuration = Integer.parseInt(invocation.getArgumentsAsArguments().get(1).getString()); try (final ExtendedJiraRestClient client = JiraAPI.load().connect(true)) { final SprintRestClient sprintClient = client.getSprintClient(); diff --git a/pj-report/src/main/java/com/g2forge/project/report/Billing.java b/pj-report/src/main/java/com/g2forge/project/report/Billing.java index 3f3d619..cc5e0ef 100644 --- a/pj-report/src/main/java/com/g2forge/project/report/Billing.java +++ b/pj-report/src/main/java/com/g2forge/project/report/Billing.java @@ -247,9 +247,9 @@ protected List examineIssue(final ExtendedJiraRestClient client, Server public static final DateTimeFormatter DATETIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm[:ss]"); @Override - public IExit invoke(CommandInvocation invocation) throws Throwable { + public IExit invoke(CommandInvocation invocation) throws Throwable { HLog.getLogControl().setLogLevel(Level.INFO); - final Arguments arguments = ArgumentParser.parse(Arguments.class, invocation.getArguments()); + final Arguments arguments = ArgumentParser.parse(Arguments.class, invocation); final Server server = HConfig.load(new PathDataSource(arguments.getServer()), Server.class); final Request request = HConfig.load(new PathDataSource(arguments.getRequest()), Request.class);