diff options
author | Cedric Beust <cedric@beust.com> | 2010-08-16 19:49:42 -0700 |
---|---|---|
committer | Cedric Beust <cedric@beust.com> | 2010-08-16 19:49:51 -0700 |
commit | 0bf62c0269798a001ef93dcf9bb9776a95f6052f (patch) | |
tree | 870aa4f6b8f8a728e7bd202183b18f1036ebd821 | |
parent | abcd2cb029dfedf65af847a2a367fcb95f7c9134 (diff) | |
download | platform_external_jcommander-0bf62c0269798a001ef93dcf9bb9776a95f6052f.tar.gz platform_external_jcommander-0bf62c0269798a001ef93dcf9bb9776a95f6052f.tar.bz2 platform_external_jcommander-0bf62c0269798a001ef93dcf9bb9776a95f6052f.zip |
Renaming
3 files changed, 40 insertions, 3 deletions
diff --git a/src/main/java/com/beust/jcommander/JCommander.java b/src/main/java/com/beust/jcommander/JCommander.java index c4bf542..a2d640a 100644 --- a/src/main/java/com/beust/jcommander/JCommander.java +++ b/src/main/java/com/beust/jcommander/JCommander.java @@ -208,7 +208,7 @@ public class JCommander { if (m_mainParameterDescription != null) { if (m_mainParameterDescription.getParameter().required() && - !m_mainParameterDescription.wasAssigned()) { + !m_mainParameterDescription.isAssigned()) { throw new ParameterException("Main parameters are required (\"" + m_mainParameterDescription.getDescription() + "\")"); } @@ -511,6 +511,7 @@ public class JCommander { } } + m_mainParameterDescription.setAssigned(true); mp.add(convertedValue); } else { @@ -688,7 +689,7 @@ public class JCommander { + (pd.getParameter().required() ? "* " : " ") + pd.getNames() + s(spaceCount) + pd.getDescription()); try { - if (! pd.wasAssigned()) { + if (! pd.isAssigned()) { Object def = pd.getField().get(pd.getObject()); if (def != null) out.append(" (default: " + def + ")"); } diff --git a/src/main/java/com/beust/jcommander/ParameterDescription.java b/src/main/java/com/beust/jcommander/ParameterDescription.java index 6adbc09..015a897 100644 --- a/src/main/java/com/beust/jcommander/ParameterDescription.java +++ b/src/main/java/com/beust/jcommander/ParameterDescription.java @@ -128,10 +128,15 @@ public class ParameterDescription { /** * @return true if this parameter received a value during the parsing phase. */ - public boolean wasAssigned() { + public boolean isAssigned() { return m_assigned; } + + public void setAssigned(boolean b) { + m_assigned = true; + } + /** * Add the specified value to the field. First look up any field converter, then * any type converter, and if we can't find any, throw an exception. diff --git a/src/test/java/com/beust/jcommander/args/ArgsRequired.java b/src/test/java/com/beust/jcommander/args/ArgsRequired.java new file mode 100644 index 0000000..69cb814 --- /dev/null +++ b/src/test/java/com/beust/jcommander/args/ArgsRequired.java @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2010 the original author or authors. + * See the notice.md file distributed with this work for additional + * information regarding copyright ownership. + * + * 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 com.beust.jcommander.args; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.internal.Lists; + +import java.util.List; + +public class ArgsRequired { + + @Parameter(description = "List of files", required = true) + public List<String> parameters = Lists.newArrayList(); + +} |