|
| 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