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


Java Command类代码示例

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


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

示例1: dateCalc

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void dateCalc(String... args) {
    final String expression = String.join(" ", args);
    final DateCalculator dc = new DateCalculator();
    try {
        final DateCalculatorResult dcr = dc.calculate(expression);
        String result = "";
        if (dcr.getDate().isPresent()) {
            result = dcr.getDate().get().toString();
        } else if (dcr.getTime().isPresent()) {
            result = dcr.getTime().get().toString();
        } else if (dcr.getDuration().isPresent()) {
            result = processDuration(dcr.getDuration().get());
            processIso8601String(dcr.getDuration().get().toString());
        } else if (dcr.getPeriod().isPresent()) {
            result = processPeriod(dcr.getPeriod().get());
            processIso8601String(dcr.getPeriod().get().toString());
        }
        System.out.println(String.format("'%s' equals '%s'", expression, result));
    } catch (DateCalcException dce) {
        System.err.println(dce.getMessage());
    }
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:24,代码来源:DateCalc.java

示例2: test

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void test(@Option("recursive") final List<Boolean> recursive,
                 @Option("links") final boolean[] links,
                 @Option("perms") final boolean perms,
                 @Option("owner") @Default("${user.name}") final String owner,
                 @Option("group") final boolean group,
                 @Option("devices") final boolean devices,
                 @Option("specials") final boolean specials,
                 @Option("times") final boolean times,
                 Patterns patterns,
                 @Option("highlight") @Default("orange,red") final Color[] highlight,
                 @Option("foreground") @Default("orange") final List<Color> foreground,
                 @Option("background") final Color[] background,
                 final URI source,
                 final URI dest
) {

}
 
开发者ID:tomitribe,项目名称:crest,代码行数:19,代码来源:HelpWithInnerOptionsTest.java

示例3: doAll

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void doAll(
        @Option("byte") @Default("42") final byte byteValue,
        @Option("char") @Default("D") final char charValue,
        @Option("boolean") @Default("true") final boolean booleanValue,
        @Option("short") @Default("1024") final short shortValue,
        @Option("int") @Default("3301976") final int intValue,
        @Option("long") @Default("10000000000") final long longValue,
        @Option("float") @Default("10.0") final float floatValue,
        @Option("double") @Default("20.0") final double doubleValue
) {
    assertEquals(defaultByte, byteValue);
    assertEquals(defaultChar, charValue);
    assertEquals(defaultBoolean, booleanValue);
    assertEquals(defaultShort, shortValue);
    assertEquals(defaultInt, intValue);
    assertEquals(defaultLong, longValue);
    assertEquals(defaultFloat, floatValue);
    assertEquals(defaultDouble, doubleValue);
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:21,代码来源:ExplicitPrimitiveOptionDefaultsTest.java

示例4: rsync

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void rsync(@Option("recursive") final boolean recursive,
                  @Option("links") final boolean links,
                  @Option("perms") final boolean perms,
                  @Option("owner") final boolean owner,
                  @Option("group") final boolean group,
                  @Option("devices") final boolean devices,
                  @Option("specials") final boolean specials,
                  @Option("times") final boolean times,
                  @Option("exclude") final Pattern exclude,
                  @Option("exclude-from") final File excludeFrom,
                  @Option("include") final Pattern include,
                  @Option("include-from") final File includeFrom,
                  @Option({"progress", "p"}) @Default("true") final boolean progress,
                  final URI[] sources,
                  final URI dest
) {

}
 
开发者ID:tomitribe,项目名称:crest,代码行数:20,代码来源:HelpTest.java

示例5: getCommandClasses

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
public static Set<Class> getCommandClasses() throws MalformedURLException {
    final File file = JarLocation.jarLocation(HelpTest.class);
    final Archive archive = ClasspathArchive.archive(Main.class.getClassLoader(), file.toURI().toURL());

    final AnnotationFinder finder = new AnnotationFinder(archive);

    final Set<Class> classes = new TreeSet<>(new Comparator<Class>() {
        @Override
        public int compare(final Class o1, final Class o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    for (final Method method : finder.findAnnotatedMethods(Command.class)) {
        classes.add(method.getDeclaringClass());
    }
    return classes;
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:19,代码来源:HelpTest.java

示例6: doAll

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void doAll(
        @Option("byte") final byte byteValue,
        @Option("char") final char charValue,
        @Option("boolean") final boolean booleanValue,
        @Option("short") final short shortValue,
        @Option("int") final int intValue,
        @Option("long") final long longValue,
        @Option("float") final float floatValue,
        @Option("double") final double doubleValue
) {
    assertEquals(uninitializedByte, byteValue);
    assertEquals(uninitializedChar, charValue);
    assertEquals(uninitializedBoolean, booleanValue);
    assertEquals(uninitializedShort, shortValue);
    assertEquals(uninitializedInt, intValue);
    assertEquals(uninitializedLong, longValue);
    assertEquals(uninitializedFloat, floatValue);
    assertEquals(uninitializedDouble, doubleValue);
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:21,代码来源:ImplicitPrimitiveOptionDefaultsTest.java

示例7: findDupes

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void findDupes(@Option("pattern") List<String> patterns,
        @Option("path") List<String> paths,
        @Option("verbose") @Default("false") boolean verbose,
        @Option("show-timings") @Default("false") boolean showTimings) {

    if (verbose) {
        System.out.println("Scanning for duplicate files.");
        System.out.println("Search paths:");
        paths.forEach(p -> System.out.println("\t" + p));
        System.out.println("Search patterns:");
        patterns.forEach(p -> System.out.println("\t" + p));
        System.out.println();
    }

    final Instant startTime = Instant.now();
    FileFinder ff = new FileFinder();
    patterns.forEach(p -> ff.addPattern(p));
    paths.forEach(p -> ff.addPath(p));

    ff.find();

    System.out.println("The following duplicates have been found:");
    java.math.BigInteger b;
    final AtomicInteger group = new AtomicInteger(1);
    ff.getDuplicates().forEach((name, list) -> {
        System.out.printf("Group #%d:%n", group.getAndIncrement());
        list.forEach(fileInfo -> System.out.println("\t" + fileInfo.getPath()));
    });
    final Instant endTime = Instant.now();

    if (showTimings) {
        Duration duration = Duration.between(startTime, endTime);
        long hours = duration.toHours();
        long minutes = duration.minusHours(hours).toMinutes();
        long seconds = duration.minusHours(hours).minusMinutes(minutes).toMillis() / 1000;
        System.out.println(String.format("%nThe scan took %d hours, %d minutes, and %d seconds.%n", hours, minutes, seconds));
    }
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:40,代码来源:DupeFinderCommands.java

示例8: doURI

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void doURI(@Option("foo") final List<URI> list) {
    assertNotNull(list);

    final Iterator<URI> it = list.iterator();
    assertEquals(URI.create("2"), it.next());
    assertEquals(URI.create("3"), it.next());
    assertEquals(URI.create("5"), it.next());
    assertFalse(it.hasNext());
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:11,代码来源:OptionListsTest.java

示例9: XbeanScanningLoader

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
public XbeanScanningLoader(final Archive archive) {
    final AnnotationFinder finder = new AnnotationFinder(archive);

    for (final Method method : finder.findAnnotatedMethods(Command.class)) {
        classes.add(method.getDeclaringClass());
    }
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:8,代码来源:XbeanScanningLoader.java

示例10: exec

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public static String exec(final Params paramNoPrefix,

                          @Option("pref.")
                          @Defaults(@Defaults.DefaultMapping(name = "p1", value = "3"))
                          final Params paramPrefixed,

                          @Option("p3") final int p3) {
    return (paramNoPrefix == null ? "null1" : paramNoPrefix.p1 + paramNoPrefix.p2) + (paramPrefixed == null ? "null2" : paramPrefixed.p1 + paramPrefixed.p2 + p3);
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:11,代码来源:NullableOptionsTest.java

示例11: doDouble

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void doDouble(final List<Double> list) {
    assertNotNull(list);

    final Iterator<Double> it = list.iterator();
    assertEquals((Double) (double) 2, it.next());
    assertEquals((Double) (double) 3, it.next());
    assertEquals((Double) (double) 5, it.next());
    assertFalse(it.hasNext());
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:11,代码来源:ArgListsTest.java

示例12: exit

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public static void exit() {
    if (exitHook != null) {
        exitHook.run();
    }
    Environment.ENVIRONMENT_THREAD_LOCAL.remove();
    throw new ExitException();
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:9,代码来源:CrestCli.java

示例13: test1

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command(interceptedBy = { In1.class, In2.class })
public String test1(
                 @Option("o1") final String o1,
                 @Option("o2") final int o2,
                 @Err final PrintStream err,
                 @Out final PrintStream out,
                 @In final InputStream is,
                 @Option("o3") final String o3,
                 final URL url) {
    return "" + o1 + o2 + Boolean.toString(err != null) + Boolean.toString(out != null) + Boolean.toString(is != null) + o3 + url.toExternalForm();
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:12,代码来源:InterceptorTest.java

示例14: cat

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public StreamingOutput cat(@IsFile @Readable final File file) {
    Files.exists(file);
    Files.readable(file);
    Files.file(file);

    return new StreamingOutput() {
        @Override
        public void write(OutputStream os) throws IOException {
            IO.copy(file, os);
        }
    };
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:14,代码来源:App.java

示例15: doLong

import org.tomitribe.crest.api.Command; //导入依赖的package包/类
@Command
public void doLong(final List<Long> list) {
    assertNotNull(list);

    final Iterator<Long> it = list.iterator();
    assertEquals((Long) (long) 2, it.next());
    assertEquals((Long) (long) 3, it.next());
    assertEquals((Long) (long) 5, it.next());
    assertFalse(it.hasNext());
}
 
开发者ID:tomitribe,项目名称:crest,代码行数:11,代码来源:ArgListsTest.java


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