xref: /Universal-ctags/Tmain/interactive-mode.d/run.sh (revision 15504fe2d0c84b6dbcb0b8a5c594424dd383185e)
1# Copyright: 2016 Aman Gupta
2# License: GPL-2
3
4CTAGS=$1
5. ../utils.sh
6
7is_feature_available ${CTAGS} interactive
8
9# It seems that the output format is slightly different between libjansson versions
10s()
11{
12	sed -e s/':"'/': "'/g
13}
14
15CTAGS="$CTAGS --options=NONE"
16
17echo identification message on startup
18echo =======================================
19${CTAGS} --_interactive < /dev/null |s
20
21echo
22echo error on invalid command
23echo =======================================
24echo '{"command":"foobar"}' | ${CTAGS} --_interactive |s
25
26echo
27echo error on missing arguments
28echo =======================================
29echo '{"command":"generate-tags"}' | ${CTAGS} --_interactive |s
30
31echo
32echo error on invalid file
33echo =======================================
34echo '{"command":"generate-tags", "filename":"test.foo"}' | ${CTAGS} --_interactive |s
35
36echo
37echo generate tags from file
38echo =======================================
39echo '{"command":"generate-tags", "filename":"test.rb"}' | ${CTAGS} --_interactive |s
40
41echo
42echo process multiple commands
43echo =======================================
44(
45  echo '{"command":"generate-tags", "filename":"test.rb"}'
46  echo '{"command":"generate-tags", "filename":"test.c"}'
47) | ${CTAGS} --_interactive |s
48
49echo
50echo generate tags from data
51echo =======================================
52size=$(filesize test.rb)
53(
54  echo '{"command":"generate-tags", "filename":"foobar.rb", "size":'$size'}'
55  cat test.rb
56) | ${CTAGS} --_interactive |s
57