Search in sources :

Example 21 with Table

use of co.cask.cdap.cli.util.table.Table in project cdap by caskdata.

the class ListDatasetTypesCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    List<DatasetTypeMeta> datasetTypeMetas = datasetTypeClient.list(cliConfig.getCurrentNamespace());
    Table table = Table.builder().setHeader("name", "modules").setRows(datasetTypeMetas, new RowMaker<DatasetTypeMeta>() {

        @Override
        public List<?> makeRow(DatasetTypeMeta object) {
            List<String> modulesStrings = Lists.newArrayList();
            for (DatasetModuleMeta module : object.getModules()) {
                modulesStrings.add(module.getName());
            }
            return Lists.newArrayList(object.getName(), Joiner.on(", ").join(modulesStrings));
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) DatasetModuleMeta(co.cask.cdap.proto.DatasetModuleMeta) RowMaker(co.cask.cdap.cli.util.RowMaker) DatasetTypeMeta(co.cask.cdap.proto.DatasetTypeMeta)

Example 22 with Table

use of co.cask.cdap.cli.util.table.Table in project cdap by caskdata.

the class ListNamespacesCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    Table table = Table.builder().setHeader("name", "description", "config").setRows(namespaceClient.list(), new RowMaker<NamespaceMeta>() {

        @Override
        public List<?> makeRow(NamespaceMeta object) {
            return Lists.newArrayList(object.getName(), object.getDescription(), NamespaceCommandUtils.prettyPrintNamespaceConfigCLI(object.getConfig()));
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta)

Example 23 with Table

use of co.cask.cdap.cli.util.table.Table in project cdap by caskdata.

the class StartProgramsCommand method runBatchCommand.

@Override
protected void runBatchCommand(PrintStream printStream, Args<BatchProgramStart> args) throws Exception {
    List<BatchProgramResult> results = programClient.start(args.appId.getParent(), args.programs);
    Table table = Table.builder().setHeader("name", "type", "error").setRows(results, new RowMaker<BatchProgramResult>() {

        @Override
        public List<?> makeRow(BatchProgramResult result) {
            return Lists.newArrayList(result.getProgramId(), result.getProgramType(), result.getError());
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, printStream, table);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker) BatchProgramResult(co.cask.cdap.proto.BatchProgramResult)

Example 24 with Table

use of co.cask.cdap.cli.util.table.Table in project cdap by caskdata.

the class StatusProgramsCommand method runBatchCommand.

@Override
protected void runBatchCommand(PrintStream printStream, Args<BatchProgram> args) throws Exception {
    List<BatchProgramStatus> results = programClient.getStatus(args.appId.getParent(), args.programs);
    Table table = Table.builder().setHeader("name", "type", "status", "error").setRows(results, new RowMaker<BatchProgramStatus>() {

        @Override
        public List<?> makeRow(BatchProgramStatus result) {
            return Lists.newArrayList(result.getProgramId(), result.getProgramType(), result.getStatus(), result.getError());
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, printStream, table);
}
Also used : BatchProgramStatus(co.cask.cdap.proto.BatchProgramStatus) Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker)

Example 25 with Table

use of co.cask.cdap.cli.util.table.Table in project cdap by caskdata.

the class StopProgramsCommand method runBatchCommand.

@Override
protected void runBatchCommand(PrintStream printStream, Args<BatchProgram> args) throws Exception {
    List<BatchProgramResult> results = programClient.stop(args.appId.getParent(), args.programs);
    Table table = Table.builder().setHeader("name", "type", "error").setRows(results, new RowMaker<BatchProgramResult>() {

        @Override
        public List<?> makeRow(BatchProgramResult result) {
            return Lists.newArrayList(result.getProgramId(), result.getProgramType(), result.getError());
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, printStream, table);
}
Also used : Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker) BatchProgramResult(co.cask.cdap.proto.BatchProgramResult)

Aggregations

Table (co.cask.cdap.cli.util.table.Table)48 RowMaker (co.cask.cdap.cli.util.RowMaker)38 CommandInputError (co.cask.cdap.cli.exception.CommandInputError)7 List (java.util.List)7 ArtifactId (co.cask.cdap.proto.id.ArtifactId)5 StreamId (co.cask.cdap.proto.id.StreamId)5 Nullable (javax.annotation.Nullable)5 ArtifactScope (co.cask.cdap.api.artifact.ArtifactScope)3 DatasetModuleMeta (co.cask.cdap.proto.DatasetModuleMeta)3 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)3 ProgramRecord (co.cask.cdap.proto.ProgramRecord)3 ApplicationId (co.cask.cdap.proto.id.ApplicationId)3 DatasetId (co.cask.cdap.proto.id.DatasetId)3 EntityId (co.cask.cdap.proto.id.EntityId)3 ProgramId (co.cask.cdap.proto.id.ProgramId)3 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)3 Map (java.util.Map)3 ArtifactInfo (co.cask.cdap.api.artifact.ArtifactInfo)2 ArtifactSummary (co.cask.cdap.api.artifact.ArtifactSummary)2 BatchProgramResult (co.cask.cdap.proto.BatchProgramResult)2