summary refs log tree commit diff
path: root/.vim/snippets/sh.lua
blob: e8ba23bec250812539856b3a17727fc40ce04df0 (plain) (blame)
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
---@diagnostic disable: undefined-global
return {
  s(
    { trig = 'getopts', desc = 'getopts skeleton' },
    fmt(
      [=[
      while getopts h{} opt; do
      	case ${{opt}} in
      	h | ?)
      		printf "usage: %s [-h]\n" "$(basename "$0")"
      		printf "\n"
      		exit 2
      		;;
      	esac
      done
      shift $((OPTIND - 1))
    ]=],
      { i(1) }
    )
  ),

  s(
    { trig = 'usage' },
    fmt(
      [=[
      usage() {{
      	printf "usage: %s{}" "$(basename "$0")\n"
      	printf "\n"
      	{}
      	printf "\n"
      }}
    ]=],
      {
        i(1, ' []'),
        i(2, 'printf "  -{}\n"'),
      }
    )
  ),
}