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