1 package org.lsst.ccs.command.demo;
2
3 import org.lsst.ccs.command.annotations.Command;
4 import org.lsst.ccs.command.annotations.Argument;
5
6
7
8
9
10
11
12
13 public class DemoCommands {
14
15 @Command(description = "Get the temperature of a module", alias = "gt")
16 public double getTemperature(@Argument(name = "module", description = "module (0-9)") int module) {
17 if (module < 0 || module > 9) {
18 throw new IllegalArgumentException("module < 0 or > 9");
19 }
20 return Math.random();
21 }
22
23 @Command(description = "Add two arguments")
24 public double add(double a, double b) {
25 return a + b;
26 }
27
28 @Command(description = "Add any number of arguments")
29 public double addAll(String base, double... numbers) {
30 double result = 0;
31 for (double d : numbers) {
32 result += d;
33 }
34 return result;
35 }
36
37 public enum Day {
38
39 SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
40 THURSDAY, FRIDAY, SATURDAY
41 }
42
43 @Command(description = "Convert day of week to an ordinal", alias = "dow, day")
44 public int dayOfWeek(@Argument(name = "Day") Day day) {
45 return day.ordinal();
46 }
47
48 @Command(description = "Always generates an error")
49 public void error() {
50 throw new UnsupportedOperationException("This command not allowed");
51 }
52
53 @Command(name = "ACrazyLongNameToTestIfHelpFormatingWorks", description = "A very long command that does nothing", level = Command.ENGINEERING1)
54 public void longCommand() {
55 }
56 }