12 from cmd_descs_util
import CD_TYPE_OLDINPUT, compute_cname, get_handler_cname
16 for file
in glob.glob(os.path.join(basedir,
"*.yaml")):
22 if "subcommands" in c
and isinstance(c[
"subcommands"], list):
26 if "subcommands" in c
and isinstance(c[
"subcommands"], str):
31 if c[
"name"] == rzcommand:
39 if "handler" in e
and e[
"handler"]:
42 if "type" in e
and e[
"type"] == CD_TYPE_OLDINPUT:
45 return f
"rz_{name}_handler"
50 with open(f,
"r", encoding=
"utf8")
as of:
51 y = yaml.safe_load(of)
56 e.get(
"type",
None), e.get(
"handler",
None), cname
64 [arg
if '"' not in arg
and "*" not in arg
else f
"'{arg}'" for arg
in args]
69 parser = argparse.ArgumentParser(
70 description=
"Find the C handler of a rizin command"
74 default=os.path.join(
"librz",
"core",
"cmd_descs"),
76 help=
"Path to the cmd_descs directory containing the *.yaml files",
82 help=
"Run the grep command directly instead of just showing it",
84 parser.add_argument(
"rzcommand", type=str, help=
"Name of the rizin command")
86 args = parser.parse_args()
92 f
"Command {args.rzcommand} does not exist or it is not converted to rzshell yet."
94 grep_cmd = [
"git",
"grep",
"-n", f
'"{args.rzcommand}"',
"librz/core/cmd"]
96 f
"Some old commands may be found like this: {CRED}{format_shell_command(grep_cmd)}{CEND}"
99 print(f
"Rizin Command: {CRED}{args.rzcommand}{CEND}")
100 print(f
"C handler: {CRED}{c_name}{CEND}")
101 grep_cmd = [
"git",
"grep",
"-nWG", f
"^[^[:blank:]].*{c_name}(",
"*.c"]
102 print(f
"Git command to get it: {CRED}{format_shell_command(grep_cmd)}{CEND}")
106 sys.exit(subprocess.run(grep_cmd, check=
False).returncode)
109 if __name__ ==
"__main__":
def get_handler_cname(ty, handler, cname)
def get_yaml_files(basedir)
def format_shell_command(args)
def find_entry(commands, rzcommand)
def get_c_handler_name_from_entry(e)
def find_c_name_handler(basedir, rzcommand)