added archived option to modify-repository sub command

This commit is contained in:
Sebastian Sdorra
2012-04-19 21:43:13 +02:00
parent 5a98895caa
commit ff27082d82
4 changed files with 118 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
/**
* Copyright (c) 2010, Sebastian Sdorra All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. Neither the name of SCM-Manager;
* nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.cli;
//~--- non-JDK imports --------------------------------------------------------
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionDef;
import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.Parameters;
import org.kohsuke.args4j.spi.Setter;
/**
*
* @author Sebastian Sdorra
*/
public class BooleanModifyOptionHandler extends OptionHandler<Boolean>
{
/**
* Constructs ...
*
*
* @param parser
* @param option
* @param setter
*/
public BooleanModifyOptionHandler(CmdLineParser parser, OptionDef option,
Setter<? super Boolean> setter)
{
super(parser, option, setter);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param params
*
* @return
*
* @throws CmdLineException
*/
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
Boolean bool = Boolean.valueOf(params.getParameter(0));
setter.addValue(bool);
return 1;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getDefaultMetaVariable()
{
return I18n.BOOLEAN;
}
}

View File

@@ -59,6 +59,9 @@ public class I18n
/** Field description */ /** Field description */
public static final String LEVEL = "level"; public static final String LEVEL = "level";
public static final String BOOLEAN = "boolean";
/** Field description */ /** Field description */
public static final String OPTIONS = "options"; public static final String OPTIONS = "options";

View File

@@ -38,6 +38,7 @@ package sonia.scm.cli.cmd;
import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option; import org.kohsuke.args4j.Option;
import sonia.scm.cli.BooleanModifyOptionHandler;
import sonia.scm.cli.I18n; import sonia.scm.cli.I18n;
import sonia.scm.cli.wrapper.RepositoryWrapper; import sonia.scm.cli.wrapper.RepositoryWrapper;
import sonia.scm.client.RepositoryClientHandler; import sonia.scm.client.RepositoryClientHandler;
@@ -133,6 +134,12 @@ public class ModifyRepositorySubCommand extends TemplateSubCommand
repository.setDescription(description); repository.setDescription(description);
} }
if (archvied != null)
{
System.out.println("ARCHIVED: " + archvied);
repository.setArchived(archvied);
}
handler.modify(repository); handler.modify(repository);
Map<String, Object> env = new HashMap<String, Object>(); Map<String, Object> env = new HashMap<String, Object>();
@@ -151,6 +158,13 @@ public class ModifyRepositorySubCommand extends TemplateSubCommand
/** /**
* TODO: public parameter * TODO: public parameter
*/ */
@Option(
name = "--archived",
usage = "optionRepositoryArchive",
aliases = { "-a" },
handler = BooleanModifyOptionHandler.class
)
private Boolean archvied;
/** Field description */ /** Field description */
@Option( @Option(

View File

@@ -49,6 +49,7 @@ optionRepositoryType = Repository name
optionRepositoryContact = Repository contact optionRepositoryContact = Repository contact
optionRepositoryDescription = Repository description optionRepositoryDescription = Repository description
optionRepositoryPublic = Repository public readable optionRepositoryPublic = Repository public readable
optionRepositoryArchive = Repository archived
optionPermissionGroup = Group optionPermissionGroup = Group
optionPermissionName = Group or user name optionPermissionName = Group or user name
@@ -84,6 +85,7 @@ repository = Repository
group = Group group = Group
user = User user = User
level = Logging-Level level = Logging-Level
boolean = true or false
options = Options options = Options
usage = scm-cli-client [options] command [command options] usage = scm-cli-client [options] command [command options]