diff --git a/src/main/java/org/springframework/shell/commands/HintCommands.java b/src/main/java/org/springframework/shell/commands/HintCommands.java deleted file mode 100644 index ba5ffdb4..00000000 --- a/src/main/java/org/springframework/shell/commands/HintCommands.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2011-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.commands; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.shell.core.CommandMarker; -import org.springframework.shell.core.annotation.CliOption; -import org.springframework.stereotype.Component; - -@Component -public class HintCommands implements CommandMarker { - - // Fields - @Autowired private HintOperations hintOperations; - - //TODO: figure out how to provide hint - //@CliCommand(value = "hint", help = "Provides step-by-step hints and context-sensitive guidance") - public String hint( - @CliOption(key = { "topic", "" }, mandatory = false, unspecifiedDefaultValue = "", optionContext = "disable-string-converter,topics", help = "The topic for which advice should be provided") final String topic) { - - return hintOperations.hint(topic); - } -} diff --git a/src/main/java/org/springframework/shell/commands/HintConverter.java b/src/main/java/org/springframework/shell/commands/HintConverter.java deleted file mode 100644 index 9fea752b..00000000 --- a/src/main/java/org/springframework/shell/commands/HintConverter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2011-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.commands; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.shell.core.Completion; -import org.springframework.shell.core.Converter; -import org.springframework.shell.core.MethodTarget; -import org.springframework.stereotype.Component; - -/** - * {@link Converter} for {@link String} that understands the "topics" option context. - * - * @author Ben Alex - * @since 1.1 - */ -@Component -public class HintConverter implements Converter { - - // Fields - @Autowired private HintOperations hintOperations; - - public String convertFromText(final String value, final Class requiredType, final String optionContext) { - return value; - } - - public boolean getAllPossibleValues(final List completions, final Class requiredType, final String existingData, final String optionContext, final MethodTarget target) { - for (String currentTopic : hintOperations.getCurrentTopics()) { - completions.add(new Completion(currentTopic)); - } - return false; - } - - public boolean supports(final Class requiredType, final String optionContext) { - return String.class.isAssignableFrom(requiredType) && optionContext.contains("topics"); - } -} diff --git a/src/main/java/org/springframework/shell/commands/HintOperations.java b/src/main/java/org/springframework/shell/commands/HintOperations.java deleted file mode 100644 index c55e2262..00000000 --- a/src/main/java/org/springframework/shell/commands/HintOperations.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2011-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.commands; - -import java.util.SortedSet; - -public interface HintOperations { - - String hint(String topic); - - SortedSet getCurrentTopics(); -} diff --git a/src/main/java/org/springframework/shell/commands/ResourceBundleHintOperations.java b/src/main/java/org/springframework/shell/commands/ResourceBundleHintOperations.java deleted file mode 100644 index 334fbf2b..00000000 --- a/src/main/java/org/springframework/shell/commands/ResourceBundleHintOperations.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2011-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.commands; - -import java.util.Enumeration; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.springframework.shell.core.AbstractShell; -import org.springframework.shell.support.util.OsUtils; -import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; - -@Component -public class ResourceBundleHintOperations implements HintOperations { - - private static ResourceBundle bundle = ResourceBundle.getBundle(HintCommands.class.getName()); - - public String hint(String topic) { - if (!StringUtils.hasText(topic)) { - topic = determineTopic(); - } - try { - String message = bundle.getString(topic); - return message.replace("\r", OsUtils.LINE_SEPARATOR).replace("${completion_key}", AbstractShell.completionKeys); - } catch (MissingResourceException exception) { - return "Cannot find topic '" + topic + "'"; - } - -} - - public SortedSet getCurrentTopics() { - SortedSet result = new TreeSet(); - String topic = determineTopic(); - if ("general".equals(topic)) { - for (Enumeration keys = bundle.getKeys(); keys.hasMoreElements();) { - result.add(keys.nextElement()); - } - // result.addAll(bundle.keySet()); ResourceBundle.keySet() method in JDK 6+ - } else { - result.add(topic); - } - return result; - } - - private String determineTopic() { - return "start"; - //return "general"; - } -} \ No newline at end of file diff --git a/src/main/resources/org/springframework/shell/commands/HintCommands.properties b/src/main/resources/org/springframework/shell/commands/HintCommands.properties deleted file mode 100644 index bb9086a5..00000000 --- a/src/main/resources/org/springframework/shell/commands/HintCommands.properties +++ /dev/null @@ -1,3 +0,0 @@ -topics= -general= -start=Welcome to the Spring Shell! To start your journey..... \ No newline at end of file