Java Code Examples for org.springframework.shell.core.annotation.CliCommand

The following examples show how to use org.springframework.shell.core.annotation.CliCommand. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@CliCommand(value = "sm variables", help = "Prints extended state variables")
public String variables() {
	StringBuilder buf = new StringBuilder();
	Set<Entry<Object, Object>> entrySet = stateMachine.getExtendedState().getVariables().entrySet();
	Iterator<Entry<Object, Object>> iterator = entrySet.iterator();
	if (entrySet.size() > 0) {
		while (iterator.hasNext()) {
			Entry<Object, Object> e = iterator.next();
			buf.append(e.getKey() + "=" + e.getValue());
			if (iterator.hasNext()) {
				buf.append("\n");
			}
		}
	} else {
		buf.append("No variables");
	}
	return buf.toString();
}
 
Example 2
Source Project: hdfs-shell   Source File: ContextCommands.java    License: Apache License 2.0 6 votes vote down vote up
@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 "";
}
 
Example 3
Source Project: gemfirexd-oss   Source File: ShellCommands.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 4
Source Project: hudi   Source File: CompactionCommand.java    License: Apache License 2.0 6 votes vote down vote up
@CliCommand(value = "compactions show all", help = "Shows all compactions that are in active timeline")
public String compactionsAll(
    @CliOption(key = {"includeExtraMetadata"}, help = "Include extra metadata",
        unspecifiedDefaultValue = "false") final boolean includeExtraMetadata,
    @CliOption(key = {"limit"}, help = "Limit commits",
        unspecifiedDefaultValue = "-1") final Integer limit,
    @CliOption(key = {"sortBy"}, help = "Sorting Field", unspecifiedDefaultValue = "") final String sortByField,
    @CliOption(key = {"desc"}, help = "Ordering", unspecifiedDefaultValue = "false") final boolean descending,
    @CliOption(key = {"headeronly"}, help = "Print Header Only",
        unspecifiedDefaultValue = "false") final boolean headerOnly)
    throws IOException {
  HoodieTableMetaClient client = checkAndGetMetaClient();
  HoodieActiveTimeline activeTimeline = client.getActiveTimeline();
  return printAllCompactions(activeTimeline,
          compactionPlanReader(this::readCompactionPlanForActiveTimeline, activeTimeline),
          includeExtraMetadata, sortByField, descending, limit, headerOnly);
}
 
Example 5
@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);
}
 
Example 6
Source Project: gemfirexd-oss   Source File: IndexCommands.java    License: Apache License 2.0 6 votes vote down vote up
@CliCommand(value = CliStrings.LIST_INDEX, help = CliStrings.LIST_INDEX__HELP)
@CliMetaData(shellOnly = false, relatedTopic={CliStrings.TOPIC_GEMFIRE_REGION, CliStrings.TOPIC_GEMFIRE_DATA})
public Result listIndex(@CliOption(key = CliStrings.LIST_INDEX__STATS,
                                   mandatory = false,
                                   specifiedDefaultValue = "true",
                                   unspecifiedDefaultValue = "false",
                                   help = CliStrings.LIST_INDEX__STATS__HELP)
                          final boolean showStats) {
  try {
    return toTabularResult(getIndexListing(), showStats);
  }
  catch (FunctionInvocationTargetException ignore) {
    return ResultBuilder.createGemFireErrorResult(CliStrings.format(CliStrings.COULD_NOT_EXECUTE_COMMAND_TRY_AGAIN,
      CliStrings.LIST_INDEX));
  }
  catch (VirtualMachineError e) {
    SystemFailure.initiateFailure(e);
    throw e;
  }
  catch (Throwable t) {
    SystemFailure.checkFailure();
    getCache().getLogger().error(t);
    return ResultBuilder.createGemFireErrorResult(String.format(CliStrings.LIST_INDEX__ERROR_MESSAGE,
      toString(t, isDebugging())));
  }
}
 
Example 7
Source Project: hudi   Source File: TableCommand.java    License: Apache License 2.0 6 votes vote down vote up
@CliCommand(value = "connect", help = "Connect to a hoodie table")
public String connect(
    @CliOption(key = {"path"}, mandatory = true, help = "Base Path of the table") final String path,
    @CliOption(key = {"layoutVersion"}, help = "Timeline Layout version") Integer layoutVersion,
    @CliOption(key = {"eventuallyConsistent"}, unspecifiedDefaultValue = "false",
        help = "Enable eventual consistency") final boolean eventuallyConsistent,
    @CliOption(key = {"initialCheckIntervalMs"}, unspecifiedDefaultValue = "2000",
        help = "Initial wait time for eventual consistency") final Integer initialConsistencyIntervalMs,
    @CliOption(key = {"maxWaitIntervalMs"}, unspecifiedDefaultValue = "300000",
        help = "Max wait time for eventual consistency") final Integer maxConsistencyIntervalMs,
    @CliOption(key = {"maxCheckIntervalMs"}, unspecifiedDefaultValue = "7",
        help = "Max checks for eventual consistency") final Integer maxConsistencyChecks)
    throws IOException {
  HoodieCLI
      .setConsistencyGuardConfig(ConsistencyGuardConfig.newBuilder().withConsistencyCheckEnabled(eventuallyConsistent)
          .withInitialConsistencyCheckIntervalMs(initialConsistencyIntervalMs)
          .withMaxConsistencyCheckIntervalMs(maxConsistencyIntervalMs).withMaxConsistencyChecks(maxConsistencyChecks)
          .build());
  HoodieCLI.initConf();
  HoodieCLI.connectTo(path, layoutVersion);
  HoodieCLI.initFS(true);
  HoodieCLI.state = HoodieCLI.CLIState.TABLE;
  return "Metadata for table " + HoodieCLI.getTableMetaClient().getTableConfig().getTableName() + " loaded";
}
 
Example 8
Source Project: hazelcast-jet-demos   Source File: MyCLI.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "KAFKA", help = "Read from Kafka into the 'precious' IMap")
public String readKafka() {
    IMap<String, List<String>> commandMap = this.hazelcastInstance.getMap(Constants.IMAP_NAME_COMMAND);

    List<String> params = new ArrayList<>();
    params.add(Constants.COMMAND_VERB_START);
    params.add(this.bootstrapServers);

    commandMap.put(Constants.COMMAND_NOUN_KAFKA, params);

    return String.format("Requested %s job '%s' with %s", Constants.COMMAND_VERB_START, Constants.COMMAND_NOUN_KAFKA, params.get(1));
}
 
Example 9
Source Project: hazelcast-jet-demos   Source File: MyCLI.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "HISTORY", help = "Recent history of changes to the 'precious' IMap")
public String readHistory() {
    IMap<String, List<String>> commandMap = this.hazelcastInstance.getMap(Constants.IMAP_NAME_COMMAND);

    List<String> params = new ArrayList<>();
    params.add(Constants.COMMAND_VERB_START);

    commandMap.put(Constants.COMMAND_NOUN_HISTORY, params);

    return String.format("Requested %s job '%s'", Constants.COMMAND_VERB_START, Constants.COMMAND_NOUN_HISTORY);
}
 
Example 10
Source Project: hudi   Source File: TableCommand.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Describes table properties.
 */
@CliCommand(value = "desc", help = "Describe Hoodie Table properties")
public String descTable() {
  HoodieTableMetaClient client = HoodieCLI.getTableMetaClient();
  TableHeader header = new TableHeader().addTableHeaderField("Property").addTableHeaderField("Value");
  List<Comparable[]> rows = new ArrayList<>();
  rows.add(new Comparable[] {"basePath", client.getBasePath()});
  rows.add(new Comparable[] {"metaPath", client.getMetaPath()});
  rows.add(new Comparable[] {"fileSystem", client.getFs().getScheme()});
  client.getTableConfig().getProps().entrySet().forEach(e -> {
    rows.add(new Comparable[] {e.getKey(), e.getValue()});
  });
  return HoodiePrintHelper.print(header, new HashMap<>(), "", false, -1, false, rows);
}
 
Example 11
Source Project: hdfs-shell   Source File: ContextCommands.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "set", help = "Set switch value")
public String set(@CliOption(key = {""}, help = "showResultCodeON/showResultCodeOFF") String commandSwitch) {
    if (commandSwitch == null) {
        return "possible parameters .... showResultCodeON/showResultCodeOFF";
    }
    if (commandSwitch.startsWith("showResultCode")) {
        showResultCode = "showResultCodeON".equalsIgnoreCase(commandSwitch);
        return commandSwitch + " has been set";
    }
    return "Unknown switch " + commandSwitch;
}
 
Example 12
Source Project: gemfirexd-oss   Source File: ShellCommands.java    License: Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 13
Source Project: hudi   Source File: CommitsCommand.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "commit rollback", help = "Rollback a commit")
public String rollbackCommit(@CliOption(key = {"commit"}, help = "Commit to rollback") final String instantTime,
    @CliOption(key = {"sparkProperties"}, help = "Spark Properties File Path") final String sparkPropertiesPath,
    @CliOption(key = "sparkMaster", unspecifiedDefaultValue = "", help = "Spark Master") String master,
    @CliOption(key = "sparkMemory", unspecifiedDefaultValue = "4G",
       help = "Spark executor memory") final String sparkMemory)
    throws Exception {
  HoodieActiveTimeline activeTimeline = HoodieCLI.getTableMetaClient().getActiveTimeline();
  HoodieTimeline completedTimeline = activeTimeline.getCommitsTimeline().filterCompletedInstants();
  HoodieTimeline filteredTimeline = completedTimeline.filter(instant -> instant.getTimestamp().equals(instantTime));
  if (filteredTimeline.empty()) {
    return "Commit " + instantTime + " not found in Commits " + completedTimeline;
  }

  SparkLauncher sparkLauncher = SparkUtil.initLauncher(sparkPropertiesPath);
  sparkLauncher.addAppArgs(SparkMain.SparkCommand.ROLLBACK.toString(), master, sparkMemory, instantTime,
      HoodieCLI.getTableMetaClient().getBasePath());
  Process process = sparkLauncher.launch();
  InputStreamConsumer.captureOutput(process);
  int exitCode = process.waitFor();
  // Refresh the current
  HoodieCLI.refreshTableMetadata();
  if (exitCode != 0) {
    return "Commit " + instantTime + " failed to roll back";
  }
  return "Commit " + instantTime + " rolled back";
}
 
Example 14
Source Project: gemfirexd-oss   Source File: DiskStoreCommands.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = CliStrings.SHOW_MISSING_DISK_STORE, help = CliStrings.SHOW_MISSING_DISK_STORE__HELP)
@CliMetaData(relatedTopic = { CliStrings.TOPIC_GEMFIRE_DISKSTORE })
public Result showMissingDiskStore() {

  try {
    TabularResultData tabularData = ResultBuilder.createTabularResultData();
    boolean accumulatedData = false;

    DistributedSystemMXBean dsMXBean = ManagementService.getManagementService(CacheFactory.getAnyInstance())
        .getDistributedSystemMXBean();
    PersistentMemberDetails[] allPersistentMemberDetails = dsMXBean.listMissingDiskStores();
    if (allPersistentMemberDetails != null) {
      for (PersistentMemberDetails peristentMemberDetails : allPersistentMemberDetails) {
        tabularData.accumulate("Disk Store ID", peristentMemberDetails.getDiskStoreId());
        tabularData.accumulate("Host", peristentMemberDetails.getHost());
        tabularData.accumulate("Directory", peristentMemberDetails.getDirectory());
        accumulatedData = true;
      }
    }

    if (!accumulatedData) {
      return ResultBuilder.createInfoResult("No missing disk store found");
   }

    return ResultBuilder.buildResult(tabularData);
  } catch (VirtualMachineError e) {
    SystemFailure.initiateFailure(e);
    throw e;
  } catch (Throwable th) {
    SystemFailure.checkFailure();
    if (th.getMessage() == null) {
      return ResultBuilder.createGemFireErrorResult("An error occurred while showing missing disk stores: " + th);
    }
    return ResultBuilder.createGemFireErrorResult("An error occurred while showing missing disk stores: " + th.getMessage());
  }
}
 
Example 15
Source Project: gemfirexd-oss   Source File: ShellCommands.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = { CliStrings.EXIT, "quit" }, help = CliStrings.EXIT__HELP)
@CliMetaData(shellOnly = true, relatedTopic = {CliStrings.TOPIC_GFSH})
public ExitShellRequest exit() throws IOException {
  Gfsh gfshInstance = getGfsh();

  gfshInstance.stop();

  ExitShellRequest exitShellRequest = gfshInstance.getExitShellRequest();
  if (exitShellRequest == null) {
    // shouldn't really happen, but we'll fallback to this anyway
    exitShellRequest = ExitShellRequest.NORMAL_EXIT;
  }

  return exitShellRequest;
}
 
Example 16
Source Project: hudi   Source File: SparkEnvCommand.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "show envs all", help = "Show spark launcher envs")
public String showAllEnv() {
  String[][] rows = new String[env.size()][2];
  int i = 0;
  for (Map.Entry<String, String> entry: env.entrySet()) {
    rows[i] = new String[]{entry.getKey(), entry.getValue()};
    i++;
  }
  return HoodiePrintHelper.print(new String[] {"key", "value"}, rows);
}
 
Example 17
Source Project: gemfirexd-oss   Source File: ShellCommands.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = { CliStrings.VERSION }, help = CliStrings.VERSION__HELP)
@CliMetaData(shellOnly=true, relatedTopic = {CliStrings.TOPIC_GFSH})
public Result version(
    @CliOption(key = { CliStrings.VERSION__FULL },
               specifiedDefaultValue = "true",
               unspecifiedDefaultValue = "false",
               help = CliStrings.VERSION__FULL__HELP)
                boolean full) {
  Gfsh gfsh = Gfsh.getCurrentInstance();

  return ResultBuilder.createInfoResult(gfsh.getVersion(full));
}
 
Example 18
Source Project: hudi   Source File: CleansCommand.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "cleans run", help = "run clean")
public String runClean(@CliOption(key = "sparkMemory", unspecifiedDefaultValue = "4G",
    help = "Spark executor memory") final String sparkMemory,
                       @CliOption(key = "propsFilePath", help = "path to properties file on localfs or dfs with configurations for hoodie client for cleaning",
                         unspecifiedDefaultValue = "") final String propsFilePath,
                       @CliOption(key = "hoodieConfigs", help = "Any configuration that can be set in the properties file can be passed here in the form of an array",
                         unspecifiedDefaultValue = "") final String[] configs,
                       @CliOption(key = "sparkMaster", unspecifiedDefaultValue = "", help = "Spark Master ") String master) throws IOException, InterruptedException, URISyntaxException {
  boolean initialized = HoodieCLI.initConf();
  HoodieCLI.initFS(initialized);
  HoodieTableMetaClient metaClient = HoodieCLI.getTableMetaClient();

  String sparkPropertiesPath =
      Utils.getDefaultPropertiesFile(JavaConverters.mapAsScalaMapConverter(System.getenv()).asScala());
  SparkLauncher sparkLauncher = SparkUtil.initLauncher(sparkPropertiesPath);

  String cmd = SparkMain.SparkCommand.CLEAN.toString();
  sparkLauncher.addAppArgs(cmd, master, sparkMemory, metaClient.getBasePath(), propsFilePath);
  UtilHelpers.validateAndAddProperties(configs, sparkLauncher);
  Process process = sparkLauncher.launch();
  InputStreamConsumer.captureOutput(process);
  int exitCode = process.waitFor();
  if (exitCode != 0) {
    return "Failed to clean hoodie dataset";
  }
  return "Cleaned hoodie dataset";
}
 
Example 19
Source Project: hudi   Source File: SparkEnvCommand.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "set", help = "Set spark launcher env to cli")
public void setEnv(@CliOption(key = {"conf"}, help = "Env config to be set") final String confMap) {
  String[] map = confMap.split("=");
  if (map.length != 2) {
    throw new IllegalArgumentException("Illegal set parameter, please use like [set --conf SPARK_HOME=/usr/etc/spark]");
  }
  env.put(map[0].trim(), map[1].trim());
}
 
Example 20
Source Project: hudi   Source File: RepairsCommand.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "repair addpartitionmeta", help = "Add partition metadata to a table, if not present")
public String addPartitionMeta(
    @CliOption(key = {"dryrun"}, help = "Should we actually add or just print what would be done",
        unspecifiedDefaultValue = "true") final boolean dryRun)
    throws IOException {

  HoodieTableMetaClient client = HoodieCLI.getTableMetaClient();
  String latestCommit =
      client.getActiveTimeline().getCommitTimeline().lastInstant().get().getTimestamp();
  List<String> partitionPaths =
      FSUtils.getAllPartitionFoldersThreeLevelsDown(HoodieCLI.fs, client.getBasePath());
  Path basePath = new Path(client.getBasePath());
  String[][] rows = new String[partitionPaths.size()][];

  int ind = 0;
  for (String partition : partitionPaths) {
    Path partitionPath = FSUtils.getPartitionPath(basePath, partition);
    String[] row = new String[3];
    row[0] = partition;
    row[1] = "Yes";
    row[2] = "None";
    if (!HoodiePartitionMetadata.hasPartitionMetadata(HoodieCLI.fs, partitionPath)) {
      row[1] = "No";
      if (!dryRun) {
        HoodiePartitionMetadata partitionMetadata =
            new HoodiePartitionMetadata(HoodieCLI.fs, latestCommit, basePath, partitionPath);
        partitionMetadata.trySave(0);
        row[2] = "Repaired";
      }
    }
    rows[ind++] = row;
  }

  return HoodiePrintHelper.print(new String[] {HoodieTableHeaderFields.HEADER_PARTITION_PATH,
      HoodieTableHeaderFields.HEADER_METADATA_PRESENT, HoodieTableHeaderFields.HEADER_ACTION}, rows);
}
 
Example 21
Source Project: hdfs-shell   Source File: HadoopDfsCommands.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = {"ls", "hdfs dfs -ls"}, help = "List the contents that match the specified file pattern.")
public String ls(
        @CliOption(key = {""}, help = "List the contents that match the specified file pattern.", specifiedDefaultValue = "", unspecifiedDefaultValue = "") String path
) {
    if (StringUtils.isEmpty(path)) {
        path = null;
    }
    return runCommand("ls", path);
}
 
Example 22
Source Project: hdfs-shell   Source File: HadoopDfsCommands.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = {"lsr", "hdfs dfs -lsr"}, help = "(DEPRECATED) Same as 'ls -R'.")
public String lsr(
        @CliOption(key = {""}, help = "(DEPRECATED) Same as 'ls -R'.") String path
) {
    if (StringUtils.isEmpty(path)) {
        path = null;
    }
    return runCommand("lsr", path);
}
 
Example 23
Source Project: gemfirexd-oss   Source File: CommandManagerJUnitTest.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = { COMMAND1_NAME, COMMAND1_NAME_ALIAS }, help = COMMAND1_HELP)
@CliMetaData(shellOnly = true, relatedTopic = { "relatedTopicOfCommand1" })
public static String command1(
    @CliArgument(name = ARGUMENT1_NAME, argumentContext = ARGUMENT1_CONTEXT, help = ARGUMENT1_HELP, mandatory = true)
    String argument1,
    @CliArgument(name = ARGUEMNT2_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;
}
 
Example 24
Source Project: hdfs-shell   Source File: HadoopDfsCommands.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = {"setfacl", "hdfs dfs -setfacl"}, help = "Sets Access Control Lists (ACLs) of files and directories.")
public String setfacl(
        @CliOption(key = {""}, help = "Sets Access Control Lists (ACLs) of files and directories.") String path
) {

    return runSetFaclCommand("setfacl", path);
}
 
Example 25
Source Project: gemfirexd-oss   Source File: GfshParserTest.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = { "testParamConcat" })
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;
}
 
Example 26
Source Project: spring-cloud-dashboard   Source File: ConfigCommands.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = {"dataflow config info"}, help = "Show the Dataflow server being used")
public String info() {

	final Map<String, String> statusValues = new TreeMap<String, String>();

	final Target target = targetHolder.getTarget();

	statusValues.put("Target", target.getTargetUriAsString());

	if (target.isSkipSslValidation()) {
		statusValues.put("SSL Validation", "skipped");
	}

	if (target.getTargetCredentials() != null) {
		statusValues.put("Credentials", target.getTargetCredentials().getDisplayableContents());
	}
	statusValues.put("Result", target.getTargetResultMessage() != null ? target.getTargetResultMessage() : "");

	final TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>();

	for (Map.Entry<String, String> row : statusValues.entrySet()) {
		modelBuilder.addRow().addValue(row.getKey()).addValue(row.getValue());
	}

	final TableBuilder builder = new TableBuilder(modelBuilder.build());
	DataFlowTables.applyStyle(builder);

	final StringBuilder sb = new StringBuilder(builder.build().render(66));

	if (Target.TargetStatus.ERROR.equals(target.getStatus())) {
		sb.append(HORIZONTAL_LINE);
		sb.append("An exception occurred during targeting:\n");

		final StringWriter stringWriter = new StringWriter();
		target.getTargetException().printStackTrace(new PrintWriter(stringWriter));

		sb.append(stringWriter.toString());
	}
	return sb.toString();
}
 
Example 27
Source Project: gemfirexd-oss   Source File: GfshParserTest.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = { COMMAND1_NAME, COMMAND1_NAME_ALIAS }, help = COMMAND1_HELP)
public static String command1(
    @CliArgument(name = ARGUMENT1_NAME, argumentContext = ARGUMENT1_CONTEXT, help = ARGUMENT1_HELP, mandatory = true)
    String argument1,
    @CliArgument(name = ARGUEMNT2_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)
    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)
    String option3) {
  return null;
}
 
Example 28
Source Project: hudi   Source File: TempViewCommand.java    License: Apache License 2.0 5 votes vote down vote up
@CliCommand(value = "temp_query", help = "query against created temp view")
public String query(
        @CliOption(key = {"sql"}, mandatory = true, help = "select query to run against view") final String sql)
        throws IOException {

  HoodieCLI.getTempViewProvider().runQuery(sql);
  return EMPTY_STRING;
}
 
Example 29
@CliCommand(value = CREATE_APPLICATION, help = "Create a new application definition")
public String createApplication(
		@CliOption(mandatory = true, key = { "", "name" }, help = "the name to give to the application") String name,
		@CliOption(mandatory = true, key = { "definition" }, help = "a application definition, using the DSL") String dsl,
		@CliOption(key = "deploy", help = "whether to deploy the application immediately", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") boolean deploy) {
	applicationOperations().createApplication(name, dsl, deploy);
	String message = String.format("Created new application '%s'", name);
	if (deploy) {
		message += "\nDeployment request has been sent";
	}
	return message;
}
 
Example 30
@CliCommand(value = DESTROY_APPLICATION_ALL, help = "Destroy all existing applications")
public String destroyAllApplications(
		@CliOption(key = "force", help = "bypass confirmation prompt", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") boolean force) {
	if (force || "y".equalsIgnoreCase(userInput.promptWithOptions("Really destroy all applications?", "n", "y", "n"))) {
		applicationOperations().destroyAll();
		return "Destroyed all applications";
	}
	else {
		return "";
	}
}