Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions server/src/snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,49 @@ export const SNIPPETS: BashCompletionItem[] = [
label: 'device',
insertText: '/dev/${1|null,stdin,stdout,stderr|}',
},
{
label: 'parse',
documentation: 'option parsing',
insertText: [
'while getopts "hv${1:single-letter-options}" ${2:option}; do',
'\tcase "\\$$2" in',
'\t\th)',
'\t\t\t${3:command for -h option ...}',
'\t\t\t;;',
'\t\tv)',
'\t\t\t${4:command for -v option ...}',
'\t\t\t;;',
'\t\t*)',
'\t\t\t${5:command ...}',
'\t\t\t;;',
'\tesac',
'done',
].join('\n'),
},
{
label: 'manual-parse',
documentation: 'manual option parsing',
insertText: [
'while [[ -n "\\$1" ]]; do',
'\tdeclare ${1:option}="\\$1"',
'\tdeclare ${2:argument}="\\$2"',
'\t',
'\tcase "\\$$1" in',
'\t\t-h|--help)',
'\t\t\t${3:command for -h/--help option ...}',
'\t\t\t;;',
'\t\t-v|--version)',
'\t\t\t${4:command for -v/--version option ...}',
'\t\t\t;;',
'\t\t*)',
'\t\t\t${5:command ...}',
'\t\t\t;;',
'\tesac',
'\t',
'\tshift',
'done',
].join('\n'),
},
{
documentation: 'completion',
label: 'completion definition',
Expand Down