Implement no-target flag

This commit is contained in:
lash 2022-02-25 11:05:56 +00:00
parent 6900c4f9a1
commit f122e2a64b
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 38 additions and 11 deletions

View File

@ -186,7 +186,8 @@ class ArgumentParser(argparse.ArgumentParser):
if arg_flags & Flag.PROVIDER:
self.add_argument('-p', '--rpc-provider', dest='p', type=str, help='RPC HTTP(S) provider url')
self.add_argument('--rpc-dialect', dest='rpc_dialect', type=str, help='RPC HTTP(S) backend dialect')
self.add_argument('--height', default='latest', help='Block height to execute against')
if arg_flags & Flag.NO_TARGET == 0:
self.add_argument('--height', default='latest', help='Block height to execute against')
if arg_flags & Flag.RPC_AUTH:
self.add_argument('--rpc-auth', dest='rpc_auth', type=str, help='RPC autentication scheme')
self.add_argument('--rpc-credentials', dest='rpc_credentials', type=str, help='RPC autentication credential values')

View File

@ -40,10 +40,10 @@ class Flag(enum.IntEnum):
# upper bound
MAX = 1048576
argflag_std_read = 0x23ff
argflag_std_write = 0x1731ff
argflag_std_base = 0x200f
argflag_std_base_read = 0xbf
argflag_std_read = 0x000023ff
argflag_std_write = 0x001731ff
argflag_std_base = 0x0000200f
argflag_std_base_read = 0x000000bf
argflag_std_target = 0x0000e000
argflag_all = 0x0317f7ff

View File

@ -224,7 +224,7 @@ class Config(confini.Config):
config.censor('PASSPHRASE', 'WALLET')
config.dict_override(args_override, 'cli args', allow_empty=True)
if arg_flags & Flag.PROVIDER:
if arg_flags & (Flag.PROVIDER | Flag.NO_TARGET) == Flag.PROVIDER:
config.add(getattr(args, 'height'), '_HEIGHT')
if arg_flags & Flag.UNSAFE:
config.add(getattr(args, 'u'), '_UNSAFE')

View File

@ -203,9 +203,10 @@ class DocGenerator:
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.')
self.docs['height'] = o
if self.arg_flags & Flag.NO_TARGET == 0:
o = DocEntry('--height')
o.set_groff('Block height at which to query state for. Does not apply to transactions.')
self.docs['height'] = o
if self.arg_flags & Flag.RPC_AUTH:
o = DocEntry('--rpc-auth')
@ -343,6 +344,10 @@ class EnvDocGenerator:
self.__add(k)
def __len__(self):
return len(self.envs)
def __str__(self):
s = ''
ks = list(self.envs.keys())

View File

@ -172,6 +172,20 @@ def get_custom(tool_name, source_dir):
return custom
def get_seealso(tool_name, source_dir):
seealso_file = os.path.join(source_dir, tool_name + '.seealso.groff')
f = None
try:
f = open(seealso_file, 'r')
except FileNotFoundError:
logg.debug('no seealso file found for {}'.format(tool_name))
return None
logg.info('seealso file {} found for {}'.format(seealso_file, tool_name))
seealso = f.read()
f.close()
return seealso
g = apply_override(g, args.source_dir)
ge = EnvDocGenerator(flags, override=args.overrides_env_dir)
@ -180,6 +194,7 @@ ge.process()
head = get_head(toolname, args.source_dir)
examples = get_examples(toolname, args.source_dir)
custom = get_custom(toolname, args.source_dir)
seealso = get_seealso(toolname, args.source_dir)
if args.overrides_config_file != None:
f = open(args.overrides_config_file, 'r')
@ -199,8 +214,14 @@ if examples != None:
f.write(".SH EXAMPLES\n\n")
f.write(examples)
f.write(".SH ENVIRONMENT\n\n")
f.write(str(ge))
if seealso != None:
seealso_description = seealso
if len(ge) > 0:
f.write(".SH ENVIRONMENT\n\n")
f.write(str(ge))
f.write(legal_description)
f.write(source_description)
f.write(seealso_description)