aboutsummaryrefslogtreecommitdiff
path: root/share/hydractl/yaml-param
blob: 1ace6c239a2e280eb9247c49e93c3781dcd18186 (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
#!/bin/bash

# Load.
source $APP_BASE/lib/hydra/functions || exit 1
hydra_config_load

# Parameters
BASENAME="`basename $0`"
PARAM="$1"
YAML_FILE="$2"
DEFAULT="$3"

# Check
if [ -z "$2" ]; then
  echo "usage: $BASENAME <param> <file> [default-value]"
  exit 1
elif [ ! -e "$YAML_FILE" ]; then
  echo "file not found: $YAML_FILE"
  exit 1
fi

# Dispatch
PARAM="`hydra_yaml_param $PARAM $YAML_FILE`"

# Display
if [ ! -z "$PARAM" ]; then
  echo "$PARAM"
elif [ ! -z "$DEFAULT" ]; then
  echo "$DEFAULT"
fi