afm-util: Remove legacy commands stop/resume
[src/app-framework-main.git] / scripts / afm-util.in
1 #!/bin/bash
2
3 send() {
4         afb-client-demo -H -d unix:@afm_platform_rundir@/apis/ws/afm-main "$1" "$2" |
5         awk '$1=="ON-REPLY" && $3!="success"{$1="ERROR:";$2="";print > "/dev/stderr";exit 1;}NR>1'
6 }
7
8 getall() {
9   case "$1" in
10     -a|--all) echo -n '{"all":true}';;
11     *) echo -n true;;
12   esac
13 }
14
15 case "$1" in
16
17   list|runnables)
18     send runnables $(getall $2)
19     ;;
20
21   add|install)
22     f=$(realpath $2)
23     r=true
24     if [[ "$(basename $0)" = "afm-install" ]]; then r=false; fi
25     send install '{"wgt":"'"$f"'","force":true,"reload":'"$r"'}'
26     ;;
27
28   remove|uninstall)
29     i=$2
30     send uninstall "\"$i\""
31     ;;
32
33   info|detail)
34     i=$2
35     send detail "\"$i\""
36     ;;
37
38   ps|runners)
39     send runners  $(getall $2)
40     ;;
41
42   run|start)
43     i=$2
44     send start "\"$i\""
45     ;;
46
47   run-remote|start-remote)
48     i=$2
49     send start '{"id":"'"$i"'","mode":"remote"}'
50     ;;
51
52   once)
53     i=$2
54     send once "\"$i\""
55     ;;
56
57   terminate|kill)
58     i=$2
59     send terminate "$i"
60     ;;
61
62   state|status)
63     i=$2
64     send state "$i"
65     ;;
66
67   -h|--help|help)
68     cat << EOC
69 usage: $(basename $0) command [arg]
70
71 The commands are:
72
73   list
74   runnables      list the runnable widgets installed
75                  option -a or --all for all instances
76
77   add wgt
78   install wgt    install the wgt file
79
80   remove id
81   uninstall id   remove the installed widget of id
82
83   info id
84   detail id      print detail about the installed widget of id
85
86   ps
87   runners        list the running instance
88                  option -a or --all for all instances
89
90   run id
91   start id       start an instance of the widget of id
92
93   once id        run once an instance of the widget of id
94
95   kill rid
96   terminate rid  terminate the running instance rid
97
98   status rid
99   state rid      get status of the running instance rid
100
101 EOC
102     ;;
103
104   *)
105     echo "unknown command $1" >&2
106     exit 1
107     ;;
108 esac
109
110