Skip to content

Commit

Permalink
Synchronized to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-ambrosio committed Oct 14, 2021
1 parent 330ce31 commit 8fee869
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 38 deletions.
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,4 @@ Copyright © 2012-2021 VLINGO LABS. All rights reserved.
This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL
was not distributed with this file, You can obtain
one at https://mozilla.org/MPL/2.0/.
# io.vlingo.bookstore
## Convert to Gradle Build

```
$ cd {project-folder}
$ gradle init
```
# io.vlingo.bookstore
## Convert to Gradle Build

```
$ cd {project-folder}
$ gradle init
```
one at https://mozilla.org/MPL/2.0/.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ public class CommandLineInterfaceInitializer {

public static void main(final String[] args) {
ComponentsRegistration.registerWith(logger, new DefaultCommandExecutionProcess(logger), loadProperties(args));

final Task task =
Task.triggeredBy(resolveCommand(args))
.orElseThrow(() -> new UnknownCommandException(args));

runTask(task, Arrays.asList(args));
runTask(Task.triggeredBy(resolveCommand(args)), Arrays.asList(args));
}

private static void runTask(final Task task,
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/io/vlingo/xoom/cli/UnknownCommandException.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ public UnknownCommandException(final String command) {
super("The informed command is not supported " + command);
}

public UnknownCommandException(final Object args) {
super("The informed command does not support arguments type " + args.getClass());
}

}
5 changes: 3 additions & 2 deletions src/main/java/io/vlingo/xoom/cli/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package io.vlingo.xoom.cli.task;

import io.vlingo.xoom.cli.CommandNotFoundException;
import io.vlingo.xoom.cli.UnknownCommandException;
import io.vlingo.xoom.cli.option.Option;
import io.vlingo.xoom.cli.option.OptionName;
import io.vlingo.xoom.cli.option.OptionValue;
Expand Down Expand Up @@ -38,10 +39,10 @@ protected Task(final String command,

public abstract void run(final List<String> args);

public static Optional<Task> triggeredBy(final String command) {
public static Task triggeredBy(final String command) {
return allTasks().stream()
.filter(task -> command != null && task.matchCommand(command.trim()))
.findFirst();
.findFirst().orElseThrow(() -> new UnknownCommandException(command));
}

public static String resolveDefaultCommand() {
Expand Down
23 changes: 12 additions & 11 deletions src/test/java/io/vlingo/xoom/cli/task/TaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.vlingo.xoom.actors.Logger;
import io.vlingo.xoom.cli.ComponentsRegistration;
import io.vlingo.xoom.cli.UnknownCommandException;
import io.vlingo.xoom.cli.XoomTurboProperties;
import io.vlingo.xoom.cli.XoomTurboProperties.ProjectPath;
import io.vlingo.xoom.cli.task.designer.DesignerTask;
Expand Down Expand Up @@ -33,17 +34,17 @@ public void setUp() {

@Test
public void testThatTasksAreFoundByCommand() {
Assertions.assertEquals(DesignerTask.class, Task.triggeredBy("gui").get().getClass());
Assertions.assertEquals(DesignerTask.class, Task.triggeredBy("designer").get().getClass());
Assertions.assertEquals(DockerPushTask.class, Task.triggeredBy("docker push").get().getClass());
Assertions.assertEquals(DockerPackageTask.class, Task.triggeredBy("docker package").get().getClass());
Assertions.assertEquals(DockerStatusTask.class, Task.triggeredBy("docker status").get().getClass());
Assertions.assertEquals(GlooInitTask.class, Task.triggeredBy("gloo init").get().getClass());
Assertions.assertEquals(GlooRouteTask.class, Task.triggeredBy("gloo route").get().getClass());
Assertions.assertEquals(GlooSuspendTask.class, Task.triggeredBy("gloo suspend").get().getClass());
Assertions.assertEquals(KubernetesPushTask.class, Task.triggeredBy("k8s push").get().getClass());
Assertions.assertEquals(VersionDisplayTask.class, Task.triggeredBy("-version").get().getClass());
Assertions.assertFalse(Task.triggeredBy("start").isPresent());
Assertions.assertEquals(DesignerTask.class, Task.triggeredBy("gui").getClass());
Assertions.assertEquals(DesignerTask.class, Task.triggeredBy("designer").getClass());
Assertions.assertEquals(DockerPushTask.class, Task.triggeredBy("docker push").getClass());
Assertions.assertEquals(DockerPackageTask.class, Task.triggeredBy("docker package").getClass());
Assertions.assertEquals(DockerStatusTask.class, Task.triggeredBy("docker status").getClass());
Assertions.assertEquals(GlooInitTask.class, Task.triggeredBy("gloo init").getClass());
Assertions.assertEquals(GlooRouteTask.class, Task.triggeredBy("gloo route").getClass());
Assertions.assertEquals(GlooSuspendTask.class, Task.triggeredBy("gloo suspend").getClass());
Assertions.assertEquals(KubernetesPushTask.class, Task.triggeredBy("k8s push").getClass());
Assertions.assertEquals(VersionDisplayTask.class, Task.triggeredBy("-version").getClass());
Assertions.assertThrows(UnknownCommandException.class, () -> Task.triggeredBy("start"));
}

@Test
Expand Down

0 comments on commit 8fee869

Please sign in to comment.