当前位置: 首页>>代码示例>>Java>>正文


Java CliOption类代码示例

本文整理汇总了Java中org.springframework.shell.core.annotation.CliOption的典型用法代码示例。如果您正苦于以下问题:Java CliOption类的具体用法?Java CliOption怎么用?Java CliOption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CliOption类属于org.springframework.shell.core.annotation包,在下文中一共展示了CliOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cd

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = "cd", help = "Changes current dir")
public String cd(@CliOption(key = {""}, help = "cd [<path>]") String newDir) {
    if (StringUtils.isEmpty(newDir)) {
        newDir = getHomeDir();
    }

    final Path path = (newDir.startsWith("/")) ? new Path(newDir) : new Path(getCurrentDir(), newDir);
    try {
        final FileSystem fs = getFileSystem();
        if (fs.exists(path) && fs.isDirectory(path)) {
            currentDir = path.toUri().getPath();
        } else {
            return "-shell: cd: " + newDir + " No such file or directory";
        }
    } catch (Exception e) {
        return "Change directory failed! " + e.getMessage();
    }
    return "";
}
 
开发者ID:avast,项目名称:hdfs-shell,代码行数:20,代码来源:ContextCommands.java

示例2: executeScript

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = {CliStrings.RUN}, help = CliStrings.RUN__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
public Result executeScript(
    @CliOption(key = CliStrings.RUN__FILE, optionContext = ConverterHint.FILE, mandatory = true,
        help = CliStrings.RUN__FILE__HELP) File file,
    @CliOption(key = {CliStrings.RUN__QUIET}, specifiedDefaultValue = "true",
        unspecifiedDefaultValue = "false", help = CliStrings.RUN__QUIET__HELP) boolean quiet,
    @CliOption(key = {CliStrings.RUN__CONTINUEONERROR}, specifiedDefaultValue = "true",
        unspecifiedDefaultValue = "false",
        help = CliStrings.RUN__CONTINUEONERROR__HELP) boolean continueOnError) {
  Result result = null;

  Gfsh gfsh = Gfsh.getCurrentInstance();
  try {
    result = gfsh.executeScript(file, quiet, continueOnError);
  } catch (IllegalArgumentException e) {
    result = ResultBuilder.createShellClientErrorResult(e.getMessage());
  } // let CommandProcessingException go to the caller

  return result;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:ShellCommands.java

示例3: debug

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = {CliStrings.DEBUG}, help = CliStrings.DEBUG__HELP)
@CliMetaData(shellOnly = true,
    relatedTopic = {CliStrings.TOPIC_GFSH, CliStrings.TOPIC_GEODE_DEBUG_UTIL})
public Result debug(
    @CliOption(key = CliStrings.DEBUG__STATE, unspecifiedDefaultValue = "OFF", mandatory = true,
        optionContext = "debug", help = CliStrings.DEBUG__STATE__HELP) String state) {
  Gfsh gfshInstance = Gfsh.getCurrentInstance();
  if (gfshInstance != null) {
    // Handle state
    if (state.equalsIgnoreCase("ON")) {
      gfshInstance.setDebug(true);
    } else if (state.equalsIgnoreCase("OFF")) {
      gfshInstance.setDebug(false);
    } else {
      return ResultBuilder.createUserErrorResult(
          CliStrings.format(CliStrings.DEBUG__MSG_0_INVALID_STATE_VALUE, state));
    }

  } else {
    ErrorResultData errorResultData =
        ResultBuilder.createErrorResultData().setErrorCode(ResultBuilder.ERRORCODE_DEFAULT)
            .addLine(CliStrings.ECHO__MSG__NO_GFSH_INSTANCE);
    return ResultBuilder.buildResult(errorResultData);
  }
  return ResultBuilder.createInfoResult(CliStrings.DEBUG__MSG_DEBUG_STATE_IS + state);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:27,代码来源:ShellCommands.java

示例4: command1

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = {COMMAND1_NAME, COMMAND1_NAME_ALIAS}, help = COMMAND1_HELP)
@CliMetaData(shellOnly = true, relatedTopic = {"relatedTopicOfCommand1"})
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public static String command1(
    @CliArgument(name = ARGUMENT1_NAME, argumentContext = ARGUMENT1_CONTEXT,
        help = ARGUMENT1_HELP, mandatory = true) String argument1,
    @CliArgument(name = ARGUMENT2_NAME, argumentContext = ARGUMENT2_CONTEXT,
        help = ARGUMENT2_HELP, mandatory = false,
        unspecifiedDefaultValue = ARGUMENT2_UNSPECIFIED_DEFAULT_VALUE,
        systemProvided = false) String argument2,
    @CliOption(key = {OPTION1_NAME, OPTION1_SYNONYM}, help = OPTION1_HELP, mandatory = true,
        optionContext = OPTION1_CONTEXT,
        specifiedDefaultValue = OPTION1_SPECIFIED_DEFAULT_VALUE) String option1,
    @CliOption(key = {OPTION2_NAME}, help = OPTION2_HELP, mandatory = false,
        optionContext = OPTION2_CONTEXT,
        specifiedDefaultValue = OPTION2_SPECIFIED_DEFAULT_VALUE) String option2,
    @CliOption(key = {OPTION3_NAME, OPTION3_SYNONYM}, help = OPTION3_HELP, mandatory = false,
        optionContext = OPTION3_CONTEXT,
        unspecifiedDefaultValue = OPTION3_UNSPECIFIED_DEFAULT_VALUE,
        specifiedDefaultValue = OPTION3_SPECIFIED_DEFAULT_VALUE) String option3) {
  return null;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:23,代码来源:CommandManagerJUnitTest.java

示例5: register

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = REGISTER_APPLICATION, help = "Register a new application")
public String register(
		@CliOption(mandatory = true,
				key = {"", "name"},
				help = "the name for the registered application")
		String name,
		@CliOption(mandatory = true,
				key = {"type"},
				help = "the type for the registered application")
				String type,
		@CliOption(mandatory = true,
				key = {"uri"},
				help = "URI for the application artifact")
		String uri,
		@CliOption(key = "force",
				help = "force update if application is already registered (only if not in use)",
				specifiedDefaultValue = "true",
				unspecifiedDefaultValue = "false")
		boolean force) {
	appRegistryOperations().register(name, type, uri, force);
	return String.format(("Successfully registered application '%s:%s'"), type, name);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dashboard,代码行数:23,代码来源:AppRegistryCommands.java

示例6: echo

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = {CliStrings.ECHO}, help = CliStrings.ECHO__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
public Result echo(@CliOption(key = {CliStrings.ECHO__STR, ""},
    unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, specifiedDefaultValue = "",
    mandatory = true, help = CliStrings.ECHO__STR__HELP) String stringToEcho) {
  Result result = null;

  if (stringToEcho.equals("$*")) {
    Gfsh gfshInstance = getGfsh();
    Map<String, String> envMap = gfshInstance.getEnv();
    Set<Entry<String, String>> setEnvMap = envMap.entrySet();
    TabularResultData resultData = buildResultForEcho(setEnvMap);

    result = ResultBuilder.buildResult(resultData);
  } else {
    result = ResultBuilder.createInfoResult(stringToEcho);
  }

  return result;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:21,代码来源:ShellCommands.java

示例7: destroyMockRegionExtension

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
/**
 * Destroy the {@link MockRegionExtension} on the given <code>regionName</code>.
 * 
 * @param regionName {@link Region} name on which to create {@link MockRegionExtension} .
 * @return {@link Result}
 * @since GemFire 8.1
 */
@CliCommand(value = DESTROY_MOCK_REGION_EXTENSION)
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result destroyMockRegionExtension(
    @CliOption(key = OPTION_REGION_NAME, mandatory = true) final String regionName) {
  return executeFunctionOnAllMembersTabulateResultPersist(
      DestroyMockRegionExtensionFunction.INSTANCE, true,
      DestroyMockRegionExtensionFunction.toArgs(regionName));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:16,代码来源:MockExtensionCommands.java

示例8: createUser

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
public String createUser(
        @CliOption(key = "login", mandatory = true, help = "Your login with alphanumeric chars") String login,
        @CliOption(key = "firstName", mandatory = true) String firstName,
        @CliOption(key = "lastName", mandatory = true) String lastName,
        @CliOption(key = "organization", mandatory = true, help = "Your organization with alphanumeric chars") String organization,
        @CliOption(key = "email", mandatory = true) String email,
        @CliOption(key = "password", mandatory = true) String password) {
    return adminUtils.createUser(login, firstName, lastName, organization,
            email, password);
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:11,代码来源:AdminCommands.java

示例9: testParamConcat

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = {"testParamConcat"})
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public static Result testParamConcat(@CliOption(key = {"string"}) String string,
    @CliOption(key = {"stringArray"}) @CliMetaData(valueSeparator = ",") String[] stringArray,
    @CliOption(key = {"stringList"}, optionContext = ConverterHint.STRING_LIST) @CliMetaData(
        valueSeparator = ",") List<String> stringList,
    @CliOption(key = {"integer"}) Integer integer,
    @CliOption(key = {"colonArray"}) @CliMetaData(valueSeparator = ":") String[] colonArray) {
  return null;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:GfshParserJUnitTest.java

示例10: testCommandManagerCreateOption

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
/**
 * tests createOption method for creating option
 */
@Test
public void testCommandManagerCreateOption() throws Exception {
  CommandManager commandManager = CommandManager.getInstance(true);
  assertNotNull(commandManager);

  Method method = Commands.class.getMethod(COMMAND1_NAME, String.class, String.class,
      String.class, String.class, String.class);

  Annotation[][] annotations = method.getParameterAnnotations();
  Class<?>[] parameterTypes = method.getParameterTypes();
  List<String> optionNames = new ArrayList<String>();
  optionNames.add(OPTION1_NAME);
  optionNames.add(OPTION2_NAME);
  optionNames.add(OPTION3_NAME);

  int parameterNo = 0;
  for (int i = 0; i < annotations.length; i++) {
    Annotation[] annotation = annotations[i];
    for (Annotation ann : annotation) {
      if (ann instanceof CliOption) {
        Option createdOption =
            commandManager.createOption((CliOption) ann, parameterTypes[i], parameterNo);
        assertTrue(optionNames.contains(createdOption.getLongOption()));
        assertEquals(((CliOption) ann).help(), createdOption.getHelp());
        if (((CliOption) ann).specifiedDefaultValue() != null
            && ((CliOption) ann).specifiedDefaultValue().length() > 0) {
          assertEquals(((CliOption) ann).specifiedDefaultValue().trim(),
              createdOption.getSpecifiedDefaultValue().trim());
        }
        if (((CliOption) ann).unspecifiedDefaultValue() != null
            && ((CliOption) ann).unspecifiedDefaultValue().length() > 0) {
          assertEquals(((CliOption) ann).specifiedDefaultValue().trim(),
              createdOption.getSpecifiedDefaultValue().trim());
        }

      }
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:43,代码来源:CommandManagerJUnitTest.java

示例11: deleteRole

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = MashCliStrings.DROP_ROLE, help = MashCliStrings.DROP_ROLE__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {MashCliStrings.TOPIC_AMPOOL_AUTHZ})
public Result deleteRole(
    @CliOption(key = MashCliStrings.DROP_ROLE__ROLE_NAME, mandatory = true,
        unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
        help = MashCliStrings.DROP_ROLE__ROLE_NAME__HELP) String roleName,
    @CliOption(key = AMPOOL_AUTHZ__SECURITY_PROPERTIES,
        optionContext = ConverterHint.FILE_PATHSTRING, mandatory = false,
        unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
        help = MashCliStrings.AMPOOL_AUTHZ__SECURITY_PROPERTIES__HELP) String secPropertiesFile) {
  Result result = null;
  if (roleName == null || roleName.length() == 0) {
    return ResultBuilder.createShellClientErrorResult(MashCliStrings.DROP_ROLE__ERROR
        + "Invalid value for " + MashCliStrings.DROP_ROLE__ROLE_NAME);
  }

  if (secPropertiesFile == null || secPropertiesFile.trim().length() == 0) {
    secPropertiesFile = getGfsh().getEnvProperty(AMPOOL_AUTHZ__SECURITY_PROPERTIES);
  }
  if (secPropertiesFile == null || secPropertiesFile.trim().length() == 0) {
    secPropertiesFile = MashLauncher.getGlobalOption(AMPOOL_AUTHZ__SECURITY_PROPERTIES);
  }

  Result err = initSecurityManager(secPropertiesFile, MashCliStrings.DROP_ROLE__ERROR);
  if (err != null)
    return err;
  try {
    securityManager.dropRole(roleName);
  } catch (Exception e) {
    return ResultBuilder
        .createShellClientErrorResult(MashCliStrings.DROP_ROLE__ERROR + e.getMessage());
  }
  securityManager.close();
  return ResultBuilder
      .createInfoResult(CliStrings.format(MashCliStrings.DROP_ROLE__SUCCESS) + roleName);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:37,代码来源:AuthorizationAdminCommands.java

示例12: deploy

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = "deploy", help = "Deploy an archive ear/war on the app servers")
public String deploy(
        @CliOption(key = "path", mandatory = true, help = "Path of the archive file") File path,
		@CliOption(key = "openBrowser", mandatory = false, help = "Open a browser to location",
		    unspecifiedDefaultValue = "true") boolean openBrowser)
		throws URISyntaxException, MalformedURLException {
    return applicationUtils.deployFromAWar(path, openBrowser);
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:9,代码来源:ApplicationCommands.java

示例13: listEnvironmentVariables

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = "list-env-var", help = "List all environment variables")
public String listEnvironmentVariables(
        @CliOption(key = "name", mandatory = false, help = HELP_APPLICATION_NAME)
        String applicationName,
        @CliOption(key = "export", mandatory = false, help = "Generate export script",
                unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
        boolean export) {
    return applicationUtils.listAllEnvironmentVariables(applicationName, export);
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:10,代码来源:ApplicationCommands.java

示例14: connect

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = "connect", help = "Connect to CloudUnit Manager")
public String connect(
        @CliOption(key = "login", mandatory = true, help = "Login") String login,
		@CliOption(key = "password", mandatory = false, help = "Password",
		    unspecifiedDefaultValue = "") String password,
		@CliOption(key = "host", mandatory = false, help = "URL for Cloudunit Manager",
		    unspecifiedDefaultValue = "") String host) {
	return authenticationUtils.connect(login, password, host, new CliPrompter());
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:10,代码来源:UserCommands.java

示例15: gc

import org.springframework.shell.core.annotation.CliOption; //导入依赖的package包/类
@CliCommand(value = CliStrings.GC, help = CliStrings.GC__HELP)
@CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_DEBUG_UTIL})
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
public Result gc(
    @CliOption(key = CliStrings.GC__GROUP,
        unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
        help = CliStrings.GC__GROUP__HELP) String[] groups,
    @CliOption(key = CliStrings.GC__MEMBER, optionContext = ConverterHint.ALL_MEMBER_IDNAME,
        unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE,
        help = CliStrings.GC__MEMBER__HELP) String memberId) {
  Cache cache = CacheFactory.getAnyInstance();
  Result result = null;
  CompositeResultData gcResultTable = ResultBuilder.createCompositeResultData();
  TabularResultData resultTable = gcResultTable.addSection().addTable("Table1");
  String headerText = "GC Summary";
  resultTable.setHeader(headerText);
  Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
  if (memberId != null && memberId.length() > 0) {
    DistributedMember member = CliUtil.getDistributedMemberByNameOrId(memberId);
    if (member == null) {
      return ResultBuilder
          .createGemFireErrorResult(memberId + CliStrings.GC__MSG__MEMBER_NOT_FOUND);
    }
    dsMembers.add(member);
    result = executeAndBuildResult(cache, resultTable, dsMembers);
  } else if (groups != null && groups.length > 0) {
    for (String group : groups) {
      dsMembers.addAll(cache.getDistributedSystem().getGroupMembers(group));
    }
    result = executeAndBuildResult(cache, resultTable, dsMembers);

  } else {
    // gc on entire cluster
    // exclude locators
    dsMembers = CliUtil.getAllNormalMembers(cache);
    result = executeAndBuildResult(cache, resultTable, dsMembers);

  }
  return result;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:41,代码来源:MiscellaneousCommands.java


注:本文中的org.springframework.shell.core.annotation.CliOption类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。