X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=scripts%2Fafm-util.in;h=45946852d7177f1e145fcb6a445acc0c61c2dd9c;hb=275f7f5b9d2b148ae61da39c87f81c75974ab31f;hp=3f47d979562a119feaaf51531bc708728f3c389f;hpb=5f7901dcb8519fe1d553bffda803a8d8da8e5af5;p=src%2Fapp-framework-main.git diff --git a/scripts/afm-util.in b/scripts/afm-util.in index 3f47d97..4594685 100755 --- a/scripts/afm-util.in +++ b/scripts/afm-util.in @@ -1,21 +1,47 @@ #!/bin/bash send() { - afb-client-demo -H -d unix:@afm_platform_rundir@/apis/ws/afm-main "$1" "$2" | - awk '$1=="ON-REPLY" && $3!="success"{$1="ERROR:";$2="";print > "/dev/stderr";exit 1;}NR>1' + local verb="$1" + afb-client-demo -H -d unix:@afm_platform_rundir@/apis/ws/afm-main "$verb" "$2" | + awk '$1=="ON-REPLY" && $3!="success"{$1="ERROR:";$2="";print > "/dev/stderr";exit 1;}NR>1' +} + +all=false +force=false +uid="$UID" +help=false + +set -- $(getopt -l all,force,help,uid: -s afhu: -n afm-util -- "$@") +while : +do + case "$1" in + -a|--all) all=true; shift;; + -f|--force) force=true; shift;; + -h|--help) help=true; shift;; + -u|--uid) uid="$2"; shift 2;; + --) shift; break;; + *) help=true; break;; + esac +done + +getall() { + case "$1" in + -a|--all) echo -n '{"all":true}';; + *) echo -n true;; + esac } case "$1" in list|runnables) - send runnables true + send runnables "{\"all\":$all,\"uid\":$uid}" ;; add|install) f=$(realpath $2) r=true if [[ "$(basename $0)" = "afm-install" ]]; then r=false; fi - send install '{"wgt":"'"$f"'","force":true,"reload":'"$r"'}' + send install "{\"wgt\":\"$f\",\"force\":$force,\"reload\":$r}" ;; remove|uninstall) @@ -25,46 +51,31 @@ case "$1" in info|detail) i=$2 - send detail "\"$i\"" + send detail "{\"id\":$i,\"uid\":$uid}" ;; ps|runners) - send runners true + send runners "{\"all\":$all,\"uid\":$uid}" ;; run|start) i=$2 - send start "\"$i\"" - ;; - - run-remote|start-remote) - i=$2 - send start '{"id":"'"$i"'","mode":"remote"}' + send start "{\"id\":$i,\"uid\":$uid}" ;; once) i=$2 - send once "\"$i\"" + send once "{\"id\":$i,\"uid\":$uid}" ;; terminate|kill) i=$2 - send terminate "$i" - ;; - - stop|pause) - i=$2 - send pause "$i" - ;; - - resume|continue) - i=$2 - send resume "$i" + send terminate "{\"runid\":$i,\"uid\":$uid}" ;; state|status) i=$2 - send state "$i" + send state "{\"runid\":$i,\"uid\":$uid}" ;; -h|--help|help) @@ -75,6 +86,7 @@ The commands are: list runnables list the runnable widgets installed + option -a or --all for all instances add wgt install wgt install the wgt file @@ -87,6 +99,7 @@ The commands are: ps runners list the running instance + option -a or --all for all instances run id start id start an instance of the widget of id @@ -96,12 +109,6 @@ The commands are: kill rid terminate rid terminate the running instance rid - stop rid - pause rid pause the running instance rid - - resume rid - continue rid continue the previously paused rid - status rid state rid get status of the running instance rid