|
|
@ -68,6 +68,9 @@ import tempfile
|
|
|
|
import textwrap
|
|
|
|
import textwrap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_PY3 = sys.version_info.major == 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _FancyFormatter(argparse.ArgumentDefaultsHelpFormatter,
|
|
|
|
class _FancyFormatter(argparse.ArgumentDefaultsHelpFormatter,
|
|
|
|
argparse.RawDescriptionHelpFormatter):
|
|
|
|
argparse.RawDescriptionHelpFormatter):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
@ -104,9 +107,7 @@ def main(sysargs=sys.argv[:]):
|
|
|
|
def _generate_flag_types(writefunc, output_go, input_json):
|
|
|
|
def _generate_flag_types(writefunc, output_go, input_json):
|
|
|
|
types = json.load(input_json)
|
|
|
|
types = json.load(input_json)
|
|
|
|
|
|
|
|
|
|
|
|
tmp = tempfile.NamedTemporaryFile(
|
|
|
|
tmp = _get_named_tmp_go()
|
|
|
|
suffix='.go', mode='w', delete=False, encoding='utf-8'
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
writefunc(tmp, types)
|
|
|
|
writefunc(tmp, types)
|
|
|
|
tmp.close()
|
|
|
|
tmp.close()
|
|
|
|
|
|
|
|
|
|
|
@ -119,6 +120,13 @@ def _generate_flag_types(writefunc, output_go, input_json):
|
|
|
|
os.remove(tmp.name)
|
|
|
|
os.remove(tmp.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_named_tmp_go():
|
|
|
|
|
|
|
|
tmp_args = dict(suffix='.go', mode='w', delete=False)
|
|
|
|
|
|
|
|
if _PY3:
|
|
|
|
|
|
|
|
tmp_args['encoding'] = 'utf-8'
|
|
|
|
|
|
|
|
return tempfile.NamedTemporaryFile(**tmp_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _set_typedef_defaults(typedef):
|
|
|
|
def _set_typedef_defaults(typedef):
|
|
|
|
typedef.setdefault('doctail', '')
|
|
|
|
typedef.setdefault('doctail', '')
|
|
|
|
typedef.setdefault('context_type', typedef['type'])
|
|
|
|
typedef.setdefault('context_type', typedef['type'])
|
|
|
|