Commit 8dfec0a8 authored by Jakub Kicinski's avatar Jakub Kicinski

tools: ynl: use operation names from spec on the CLI

When I wrote the first version of the Python code I was quite
excited that we can generate class methods directly from the
spec. Unfortunately we need to use valid identifiers for method
names (specifically no dashes are allowed). Don't reuse those
names on the CLI, it's much more natural to use the operation
names exactly as listed in the spec.

Instead of:
  ./cli --do rings_get
use:
  ./cli --do rings-get
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4cd2796f
...@@ -32,10 +32,11 @@ def main(): ...@@ -32,10 +32,11 @@ def main():
if args.sleep: if args.sleep:
time.sleep(args.sleep) time.sleep(args.sleep)
if args.do or args.dump: if args.do:
method = getattr(ynl, args.do if args.do else args.dump) reply = ynl.do(args.do, attrs)
pprint.PrettyPrinter().pprint(reply)
reply = method(attrs, dump=bool(args.dump)) if args.dump:
reply = ynl.dump(args.dump, attrs)
pprint.PrettyPrinter().pprint(reply) pprint.PrettyPrinter().pprint(reply)
if args.ntf: if args.ntf:
......
...@@ -520,3 +520,9 @@ class YnlFamily(SpecFamily): ...@@ -520,3 +520,9 @@ class YnlFamily(SpecFamily):
if not dump and len(rsp) == 1: if not dump and len(rsp) == 1:
return rsp[0] return rsp[0]
return rsp return rsp
def do(self, method, vals):
return self._op(method, vals)
def dump(self, method, vals):
return self._op(method, vals, dump=True)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment