Refactorization of gws

This commit is contained in:
Martin Blazik
2020-10-02 15:28:54 +02:00
parent 8cb6cc467b
commit 1fc9955ff5

27
bin/gws
View File

@@ -2,16 +2,15 @@
"""
TODO
could load shortcuts from envinroment
could load shortcuts from environment
"""
import os
from sys import argv, exit
shortcuts = {
'buildTest': ['compileTestKotlin'],
'btest': ['compileTestKotlin'],
'composite': ['compositeTest'],
'bt': ['compileTestKotlin'],
'ct': ['componentTest'],
'cb': ['clean', 'build'],
'cbx': ['clean', 'build', '-x', 'test'],
'cbt': ['clean', 'build', 'compileTestKotlin'],
@@ -19,16 +18,14 @@ shortcuts = {
'-rr': ['--rerun-tasks']
}
# must keep next argument
options = set(['-x', '-b', '-c', '-g', '-p', '-D', '-I', '-P'])
optionsWithArgument = set(['-x', '-b', '-c', '-g', '-p', '-D', '-I', '-P'])
help_text = """\
Support functionality for gw application
gws means gw script
Use cases
gws clean build -x test :test :tools
gws cb
gws cb ct
gws cbt
gws cbx :microservices:afm-exec-api
@@ -37,11 +34,11 @@ Options
"""
def help():
def show_help():
print(help_text)
show_shortcuts()
exit(0)
print()
exit(1)
def show_shortcuts():
@@ -50,7 +47,6 @@ def show_shortcuts():
print(' {} ... {}'.format(key, ' '.join(value)))
def flat_map(f, xs):
return (y for ys in xs for y in f(ys))
@@ -60,7 +56,7 @@ def split_options(args):
while True:
try:
arg = next(iterator)
if arg in options:
if arg in optionsWithArgument:
yield [arg, next(iterator)]
else:
yield [arg]
@@ -101,8 +97,8 @@ def prepare_command(args):
def main(args):
if (not args):
help()
if not args:
show_help()
cmd = prepare_command(args)
print('## ' + cmd)
if '--dry' not in args:
@@ -111,4 +107,3 @@ def main(args):
if __name__ == '__main__':
main(argv[1:])