1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.cling.invoker.mvnenc.goals;
20
21 import org.apache.maven.api.services.MessageBuilderFactory;
22 import org.apache.maven.cling.invoker.mvnenc.EncryptContext;
23 import org.apache.maven.cling.invoker.mvnenc.EncryptInvoker;
24 import org.codehaus.plexus.components.secdispatcher.SecDispatcher;
25
26
27
28
29 public abstract class InteractiveGoalSupport extends GoalSupport {
30 protected InteractiveGoalSupport(MessageBuilderFactory messageBuilderFactory, SecDispatcher secDispatcher) {
31 super(messageBuilderFactory, secDispatcher);
32 }
33
34 @Override
35 public int execute(EncryptContext context) throws Exception {
36 if (!context.interactive) {
37 context.terminal.writer().println("This tool works only in interactive mode!");
38 context.terminal
39 .writer()
40 .println("Tool purpose is to configure password management on developer workstations.");
41 context.terminal
42 .writer()
43 .println(
44 "Note: Generated configuration can be moved/copied to headless environments, if configured as such.");
45 return EncryptInvoker.BAD_OPERATION;
46 }
47
48 return doExecute(context);
49 }
50
51 protected abstract int doExecute(EncryptContext context) throws Exception;
52 }