From 49a4e4b4b8deff3370a22dd90a9b7d15f3e4f5b2 Mon Sep 17 00:00:00 2001 From: lash Date: Wed, 23 Feb 2022 10:32:44 +0000 Subject: [PATCH] Add remaining man page contents --- chainlib/cli/man.py | 16 ++++++++--- scripts/chainlib-man.py | 62 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/chainlib/cli/man.py b/chainlib/cli/man.py index 967246c..eb5c6f0 100644 --- a/chainlib/cli/man.py +++ b/chainlib/cli/man.py @@ -20,6 +20,7 @@ def apply_groff(collection, v, arg=None, typ='arg'): if len(s) > 0: s += ', ' s += format_groff(flag, v, arg=arg, typ=typ) + s = "\n.TP\n" + s + "\n" + v return s @@ -33,7 +34,6 @@ def format_groff(k, v, arg=None, typ='arg'): if arg != None: s += ' \\fI' + arg s += '\\fP' - s = "\n.TP\n" + s + "\n" + v return s @@ -87,6 +87,7 @@ class DocGenerator: #self.config = config self.arg_flags = arg_flags self.docs = {} + self.envs = {} # self.envs = {} @@ -151,7 +152,7 @@ class DocGenerator: self.docs['n'] = o o = DocEntry('--dumpconfig', argvalue='format') - o.set_groff('Output configuration settings rendered from environment and inputs. Valid arguments are \\fIini\\fP for ini file output, and \\fIenv\\fP for environment variable output') + o.set_groff('Output configuration settings rendered from environment and inputs. Valid arguments are \\fIini\\fP for ini file output, and \\fIenv\\fP for environment variable output. See \\fBCONFIGURATION\\fP.') self.docs['dumpconfig'] = o @@ -175,10 +176,12 @@ class DocGenerator: o = DocEntry('-p', '--rpc-provider') o.set_groff('Fully-qualified URL of RPC provider.') self.docs['p'] = o + self.envs['p'] = 'RPC_PROVIDER' o = DocEntry('--rpc-dialect') o.set_groff('RPC backend dialect. If specified it \\fImay\\fP help with encoding and decoding issues.') self.docs['rpcdialect'] = o + self.envs['rpcdialect'] = 'RPC_DIALECT' o = DocEntry('--height') o.set_groff('Block height at which to query state for. Does not apply to transactions.') @@ -188,16 +191,19 @@ class DocGenerator: o = DocEntry('--rpc-auth') o.set_groff('RPC endpoint authentication method, e.g. how to handle a HTTP WWW-Authenticate header.') self.docs['rpcauth'] = o + self.envs['rpcauth'] = 'RPC_AUTH' o = DocEntry('--rpc-credentials') o.set_groff('RPC endpoint authentication data. Format depends on the authentication method defined in \\fB--rpc-auth\\fP.') - self.docs['rpcendpoint'] = o + self.docs['rpccredentials'] = o + self.envs['rpccredentials'] = 'RPC_CREDENTIALS' if self.arg_flags & Flag.CHAIN_SPEC: o = DocEntry('-i', '--chain-spec', argvalue='chain_spec') o.set_groff('Chain specification string, in the format :::. Example: "evm:london:1:ethereum".') self.docs['i'] = o + self.envs['i'] = 'RPC_CREDENTIALS' if self.arg_flags & Flag.UNSAFE: @@ -216,6 +222,7 @@ class DocGenerator: o = DocEntry('-y', '--key-path', argvalue='path') o.set_groff('Path to signing key.') self.docs['y'] = o + self.envs['y'] = 'WALLET_KEY_FILE' o = DocEntry('--passphrase-file', argvalue='path') o.set_groff('Path to file containing password to unlock key file') @@ -282,7 +289,8 @@ class EnvDocGenerator: def __add(self, k): - v = format_groff(k, self.config.get(k), None, typ='env') + #v = format_groff(k, self.config.get(k), None, typ='env') + v = apply_groff([k], self.config.get(k), None, typ='env') self.envs[k] = v diff --git a/scripts/chainlib-man.py b/scripts/chainlib-man.py index 538796d..598ba9a 100644 --- a/scripts/chainlib-man.py +++ b/scripts/chainlib-man.py @@ -22,6 +22,58 @@ from chainlib.eth.cli.config import Config logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() + +configuration_description = """ +.SH CONFIGURATION + +All configuration settings may be overriden both by environment variables, or by overriding settings with the contents of ini-files in the directory defined by the \\fB-c\\fP option. + +The active configuration, with values assigned from environment and arguments, can be output using the \\fB--dumpconfig\\fP \\fIformat\\fP option. Note that entries having keys prefixed with underscore (e.g. _SEQ) are not actual configuration settings, and thus cannot be overridden with environment variables. + +To refer to a configuration setting by environment variables, the \\fIsection\\fP and \\fIkey\\fP are concatenated together with an underscore, and transformed to upper-case. For example, the configuration variable \\fIFOO_BAZ_BAR\\fP refers to an ini-file entry as follows: + +.EX +[foo] +bar_baz = xyzzy +.EE + +In the \\fBENVIRONMENT\\fP section below, the relevant configuration settings for this tool is listed along with a short description of its meaning. + +Some configuration settings may also be overriden by command line options. Also note that the use of the \\fB-n\\fP and \\fB--env-prefix\\fP options affect how environment and configuration is read. The effects of options on how configuration settings are affective is described in the respective \\fBOPTIONS\\fP section. + +""" + +seealso_description = """ +.SH SEE ALSO + +.BP +confini-dump(1), eth-keyfile(1) + +""" + +legal_description = """ +.SH LICENSE + +This documentation and its source is licensed under the Creative Commons Attribution-Sharealike 4.0 International license. + +The source code of the tool this documentation describes is licensed under the GNU General Public License 3.0. + +.SH COPYRIGHT + +.P +Louis Holbrook (https://holbrook.no) +PGP: 59A844A484AC11253D3A3E9DCDCBD24DD1D0E001 + +""" + +source_description = """ + +.SH SOURCE CODE + +https://git.defalsify.org + +""" + argparser = argparse.ArgumentParser() argparser.add_argument('-b', default=add_0x(hex(argflag_std_base)), help='argument flag bitmask') argparser.add_argument('-c', help='config override directory') @@ -30,6 +82,7 @@ argparser.add_argument('-d', default='.', help='output directory') argparser.add_argument('-v', action='store_true', help='turn on debug logging') argparser.add_argument('--overrides-file', dest='overrides_file', help='load options description override from file') argparser.add_argument('--overrides-env-dir', dest='overrides_env_dir', help='load envionment description override config from directory') +argparser.add_argument('--overrides-config-file', dest='overrides_config_file', help='load configuration text from file') argparser.add_argument('header_file', help='groff file containing heading, synopsis and description') args = argparser.parse_args(sys.argv[1:]) @@ -75,12 +128,21 @@ f = open(args.header_file) head = f.read() f.close() +if args.overrides_config_file != None: + f = open(args.overrides_config_file, 'r') + configuration_description = f.read() + f.close() + (fd, fp) = tempfile.mkstemp() f = os.fdopen(fd, 'w') f.write(head) f.write(str(g)) +f.write(configuration_description) f.write(".SH ENVIRONMENT\n\n") f.write(str(ge)) +f.write(legal_description) +f.write(source_description) +f.write(seealso_description) f.close() dest = os.path.join(args.d, toolname + '.1')