summaryrefslogtreecommitdiff
path: root/run
blob: fba47aa98986cbff53c79efb786735adde192224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash

NNFW_SCRIPT_RPATH="scripts"
NNFW_COMMAND_RPATH="${NNFW_SCRIPT_RPATH}/command"

NNFW_PROJECT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
NNFW_SCRIPT_PATH="${NNFW_PROJECT_PATH}/${NNFW_SCRIPT_RPATH}"

function Usage()
{
  echo "Usage: $0 [COMMAND] ..."
  echo "Command:"
  for file in "$NNFW_COMMAND_RPATH"/*;
  do
    echo "  $(basename "$file")"
  done
}

COMMAND=$1; shift

if [[ -z "${COMMAND}" ]]; then
  Usage
  exit 255
fi

COMMAND_FILE="${NNFW_PROJECT_PATH}/${NNFW_COMMAND_RPATH}/${COMMAND}"

if [[ ! -f "${COMMAND_FILE}" ]]; then
  echo "ERROR: '${COMMAND}' is not supported"
  exit 255
fi

export NNFW_PROJECT_PATH
export NNFW_SCRIPT_PATH

source "${COMMAND_FILE}" "$@"