Skip to content

Commit

Permalink
Merge pull request #31 from jonx8/commands
Browse files Browse the repository at this point in the history
Change help
  • Loading branch information
jonx8 authored Sep 30, 2023
2 parents cde41ca + 80b80dd commit 2d50050
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
10 changes: 7 additions & 3 deletions src/main/java/ru/etu/petci/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Main {
LOGGER = Logger.getLogger(Main.class.getName());

commandHandlersMap.put("init", new InitCommand());
commandHandlersMap.put("continue", new ContinueCommand());
commandHandlersMap.put("observe", new ObserveCommand());
commandHandlersMap.put("job", new JobCommand());
}

Expand All @@ -51,7 +51,11 @@ public static void main(String[] args) {
public static void showHelp() {
System.out.println("Commands: ");
System.out.println("init - configure repository for work with CI");
System.out.println("continue - start repository monitoring");
System.out.println("add - add new job");
System.out.println("observe - start repository monitoring");
System.out.println("job <command> [arg]");
System.out.println("\tdelete <job name> - delete job");
System.out.println("\tactivate <job name> - activate job");
System.out.println("\tdeactivate <job name> - activate job");
System.out.println("\tlist - show list of jobs");
}
}
15 changes: 3 additions & 12 deletions src/main/java/ru/etu/petci/handlers/JobCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.HashMap;
import java.util.Map;

import static ru.etu.petci.Main.showHelp;

public class JobCommand implements Command {
private static final Map<String, Command> commandMap = new HashMap<>();

Expand All @@ -14,7 +16,6 @@ public class JobCommand implements Command {
commandMap.put("list", new ListJobCommand());
}


@Override
public int handle(String[] args) {
if (args.length > 1) {
Expand All @@ -23,17 +24,7 @@ public int handle(String[] args) {
return cmd.handle(args);
}
}
showJobHelp();
showHelp();
return 1;
}


private void showJobHelp() {
System.out.println("Job command help:");
System.out.println("add - add new job");
System.out.println("delete (job name) - delete job");
System.out.println("activate (job name) - activate job");
System.out.println("deactivate (job name) - activate job");
System.out.println("list - show list of jobs");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import java.util.List;
import java.util.logging.Logger;

public class ContinueCommand implements Command {
public class ObserveCommand implements Command {

private static final Logger LOGGER = Logger.getLogger(ContinueCommand.class.getName());
private static final Logger LOGGER = Logger.getLogger(ObserveCommand.class.getName());

@Override
public int handle(String[] args) {
Expand Down

0 comments on commit 2d50050

Please sign in to comment.