Publish some Sublime Text snippets.

This commit is contained in:
Ethan Dalool 2019-04-16 18:39:00 -07:00
parent 007b4a6e62
commit 0dbc0728c0
7 changed files with 146 additions and 0 deletions

View file

@ -0,0 +1,30 @@
<snippet>
<content><![CDATA[
import argparse
import sys
def $1_argparse(args):
print(args)
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('required_positional')
parser.add_argument('optional_positional', nargs='?', default=None)
parser.add_argument('-k', '--kwarg', dest='kwarg', default=None)
parser.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
parser.set_defaults(func=$1_argparse)
args = parser.parse_args(argv)
args.func(args)
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))
]]></content>
<tabTrigger>argparse</tabTrigger>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>

View file

@ -0,0 +1,32 @@
<snippet>
<content><![CDATA[
import argparse
import sys
def $1_argparse(args):
print(args)
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)
subparsers = parser.add_subparsers()
p_example = subparsers.add_parser('example1')
p_example.add_argument('required_positional')
p_example.add_argument('optional_positional', nargs='?', default=None)
p_example.add_argument('-k', '--kwarg', dest='kwarg', default=None)
p_example.add_argument('-b', '--boolkwarg', dest='boolkwarg', action='store_true')
p_example.set_defaults(func=$1_argparse)
args = parser.parse_args(argv)
args.func(args)
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))
]]></content>
<tabTrigger>argparse_multi</tabTrigger>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>

View file

@ -0,0 +1,15 @@
<snippet>
<content><![CDATA[
def main(argv):
return 0
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))
]]></content>
<tabTrigger>defmain</tabTrigger>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>

View file

@ -0,0 +1,12 @@
<snippet>
<content><![CDATA[
if __name__ == '__main__':
raise SystemExit(main(sys.argv[1:]))
]]></content>
<tabTrigger>ifmain</tabTrigger>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>

View file

@ -0,0 +1,14 @@
<snippet>
<content><![CDATA[
def listget(l, index, default=None):
try:
return l[index]
except IndexError:
return default
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
<tabTrigger>listget</tabTrigger>
</snippet>

View file

@ -0,0 +1,11 @@
<snippet>
<content><![CDATA[
raise NotImplementedError
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
<tabTrigger>ni</tabTrigger>
<description>raise NotImplementedError</description>
</snippet>

View file

@ -0,0 +1,32 @@
<snippet>
<content><![CDATA[
<!DOCTYPE html5>
<html>
<head>
{% import "header.html" as header %}
<title>Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="/static/common.css">
<script src="/static/common.js"></script>
<style>
</style>
</head>
<body>
</body>
<script type="text/javascript">
</script>
</html>
]]></content>
<tabTrigger>webpage</tabTrigger>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<!-- <tabTrigger>hello</tabTrigger> -->
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>