Add heading file argument to generator script

This commit is contained in:
lash 2022-02-22 12:11:38 +00:00
parent 299b680748
commit 3691f75f81
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
4 changed files with 44 additions and 5 deletions

View File

@ -1,3 +1,5 @@
- 0.0.22
* Add man page generator script
- 0.0.21
* Log rpc reply before json parse
- 0.0.20

View File

@ -193,7 +193,7 @@ class DocGenerator:
self.docs['feeprice'] = o
o = DocEntry('--fee-limit')
o.set_groff('Set the limit of execution units for the transaction. If used with \\fB-s\fP this may incur actual network token cost. If \\fB--fee-price\\fP is not explicitly set, the price \\fImay\\fP be retrieved from the network, and multiplied with this value to define the cost.')
o.set_groff('Set the limit of execution units for the transaction. If used with \\fB-s\\fP this may incur actual network token cost. If \\fB--fee-price\\fP is not explicitly set, the price \\fImay\\fP be retrieved from the network, and multiplied with this value to define the cost.')
self.docs['feelimit'] = o
# TODO: this manipulation should be DRYd

View File

@ -1,8 +1,42 @@
import os
import sys
from hexathon import strip_0x
from chainlib.cli.man import DocGenerator
import argparse
import tempfile
import shutil
b = bytes.fromhex(strip_0x(sys.argv[1]))
from hexathon import strip_0x, add_0x
from chainlib.cli.man import DocGenerator
from chainlib.cli.base import argflag_std_base
argparser = argparse.ArgumentParser()
argparser.add_argument('-b', default=add_0x(hex(argflag_std_base)), help='argument flag bitmask')
argparser.add_argument('-n', help='tool name to use for man filename')
argparser.add_argument('-d', default='.', help='output directory')
argparser.add_argument('header_file', help='groff file containing heading, synopsis and description')
args = argparser.parse_args(sys.argv[1:])
#b = bytes.fromhex(strip_0x(sys.argv[1]))
b = bytes.fromhex(strip_0x(args.b))
g = DocGenerator(int.from_bytes(b, byteorder='little'))
g.process()
print(g)
f = open(args.header_file)
head = f.read()
f.close()
toolname = args.n
if toolname == None:
parts = os.path.splitext(os.path.basename(args.header_file))
toolname = parts[0]
(fd, fp) = tempfile.mkstemp()
f = os.fdopen(fd, 'w')
f.write(head)
f.write(str(g))
f.close()
dest = os.path.join(args.d, toolname + '.1')
shutil.copyfile(fp, dest)
os.unlink(fp)

View File

@ -24,4 +24,7 @@ setup(
'chainlib',
'chainlib.cli',
],
scripts = [
'scripts/man.py',
],
)