summaryrefslogtreecommitdiff
path: root/scorsh.sh
blob: fefac2dc0ef5898d5a2b247184f4612a87b13122 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh

##
## Rudimentary implementation of a scorsh client, in POSIX sh
##

## func
build_command(){

    CMD=$1
    shift
    ARGS=$@

    ARGLIST=""
    for a in ${ARGS}; do
        ARGLIST="${ARGLIST}\"$a\","
    done
    ARGLIST=$(echo ${ARGLIST}| sed -r -e 's/,$//g')
    
    cmd_str=$(cat <<EOF
---
scorsh:
  [ 
    {
     s_cmd: "$CMD",
     s_args: [${ARGLIST}]
    }
  ]
...
EOF
           )
    
}


if [ $# -le 0 ]; then
    echo "Usage: $0 <cmd> [<arg>...]" 
    exit 1
fi

echo $@

build_command $@

echo $@

echo "${cmd_str}"

echo "$0"


## Check if we have to create the commit
script_name=$(basename $0)
echo "script_name: ${script_name}"
if [ "${script_name}" = "scorsh-commit" ]; then
    
    git commit --allow-empty -Sscorsh -m "${cmd_str}"
    
fi