88package org .epics .pva .client ;
99
1010import java .util .ArrayList ;
11+ import java .util .Arrays ;
1112import java .util .Iterator ;
1213import java .util .List ;
1314import java .util .concurrent .CountDownLatch ;
1718import java .util .logging .Level ;
1819import java .util .logging .LogManager ;
1920import java .util .logging .Logger ;
21+ import java .util .stream .Collectors ;
2022
2123import org .epics .pva .PVASettings ;
2224import org .epics .pva .data .PVAData ;
@@ -38,9 +40,17 @@ public class PVAClientMain
3840 private static boolean completion = false ;
3941 private static String request = "" ;
4042
43+ /** Commands */
44+ private static enum Cmd
45+ {
46+ info , get , monitor , put , call , beacons
47+ }
48+
4149 private static void help ()
4250 {
43- System .out .println ("USAGE: pvaclient info|get|monitor|put|call|beacons [options] <PV name>..." );
51+ System .out .println ("USAGE: pvaclient " +
52+ Arrays .stream (Cmd .values ()).map (Object ::toString ).collect (Collectors .joining ("|" )) +
53+ " [options] <PV name>..." );
4454 System .out .println ();
4555 System .out .println ("Options:" );
4656 System .out .println (" -h Help" );
@@ -368,22 +378,22 @@ else if (arg.startsWith("-"))
368378
369379 final String command = names .remove (0 );
370380
371- if (command .equals (" beacons" ) && names .size () == 0 )
381+ if (command .equals (Cmd . beacons . name () ) && names .size () == 0 )
372382 beacons ();
373- else if (command .equals (" info" ) && names .size () > 0 )
383+ else if (command .equals (Cmd . info . name () ) && names .size () > 0 )
374384 info (names );
375- else if (command .equals (" get" ) && names .size () > 0 )
385+ else if (command .equals (Cmd . get . name () ) && names .size () > 0 )
376386 get (names );
377- else if (command .equals (" monitor" ) && names .size () > 0 )
387+ else if (command .equals (Cmd . monitor . name () ) && names .size () > 0 )
378388 monitor (names );
379- else if (command .equals (" put" ) && names .size () == 2 )
389+ else if (command .equals (Cmd . put . name () ) && names .size () == 2 )
380390 {
381391 // By default, write to the 'value' element data structure
382392 if (request .isEmpty ())
383393 request = "value" ;
384394 put (names .get (0 ), names .get (1 ));
385395 }
386- else if (command .equals (" call" ) && names .size () > 0 )
396+ else if (command .equals (Cmd . call . name () ) && names .size () > 0 )
387397 {
388398 // For now not supporting any request detail from cmdline
389399 PVAStructure request = new PVAStructure ("" , "" );
0 commit comments