Skip to content

Commit 60d91e7

Browse files
committed
New command "proxy"
1 parent 12cac0b commit 60d91e7

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

src/main/java/org/telosys/tools/cli/CommandProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.telosys.tools.cli.commands.ModelCommand;
6161
import org.telosys.tools.cli.commands.NewEntityCommand;
6262
import org.telosys.tools.cli.commands.NewModelCommand;
63+
import org.telosys.tools.cli.commands.ProxyCommand;
6364
import org.telosys.tools.cli.commands.PwdCommand;
6465
import org.telosys.tools.cli.commands.QuitCommand;
6566
import org.telosys.tools.cli.commands.TestCommand;
@@ -103,6 +104,7 @@ private final void init(ConsoleReader consoleReader, Environment environment) {
103104
register(new ExitCommand(consoleReader, environment)); // exit ( ver 4.1.0 )
104105
register(new ErrorCommand(consoleReader, environment)); // err
105106
register(new VerCommand(consoleReader, environment)); // ver
107+
register(new ProxyCommand(consoleReader, environment)); // proxy ( ver 4.1.1 )
106108

107109
register(new TestCommand(consoleReader, environment)); // Special command (just for tests)
108110

src/main/java/org/telosys/tools/cli/CommandsGroups.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private final CommandsGroup getGlobalCommands() {
5858
commands.add("fx");
5959
commands.add("err");
6060
commands.add("env");
61+
commands.add("proxy");
6162
commands.add("ver");
6263
commands.add("q");
6364
commands.add("exit");
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* Copyright (C) 2015-2019 Telosys project org. ( http://www.telosys.org/ )
3+
*
4+
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.gnu.org/licenses/lgpl.html
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.telosys.tools.cli.commands;
17+
18+
import java.io.File;
19+
20+
import org.telosys.tools.cli.Command;
21+
import org.telosys.tools.cli.Environment;
22+
import org.telosys.tools.commons.http.HttpSystemConfig;
23+
24+
import jline.console.ConsoleReader;
25+
26+
public class ProxyCommand extends Command {
27+
28+
/**
29+
* Constructor
30+
* @param consoleReader
31+
* @param environment
32+
*/
33+
public ProxyCommand(ConsoleReader consoleReader, Environment environment) {
34+
super(consoleReader, environment);
35+
}
36+
37+
@Override
38+
public String getName() {
39+
return "proxy";
40+
}
41+
42+
@Override
43+
public String getShortDescription() {
44+
return "Proxy configuration" ;
45+
}
46+
47+
@Override
48+
public String getDescription() {
49+
return "Get current proxy configuration ";
50+
}
51+
52+
@Override
53+
public String getUsage() {
54+
return "proxy";
55+
}
56+
57+
@Override
58+
public String execute(String[] args) {
59+
// Reset configuration from config file
60+
String configFile = getTelosysToolsCfgFullPath();
61+
if ( configFile != null ) {
62+
HttpSystemConfig.init(new File(configFile));
63+
}
64+
// Get and print configuration
65+
for ( String s : HttpSystemConfig.getCurrentHttpConfig() ) {
66+
print(s);
67+
}
68+
for ( String s : HttpSystemConfig.getCurrentProxyConfig() ) {
69+
print(s);
70+
}
71+
return null ;
72+
}
73+
74+
}

0 commit comments

Comments
 (0)