linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	sdf@google.com, linux-doc@vger.kernel.org,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v2 09/14] tools: ynl: use operation names from spec on the CLI
Date: Mon, 30 Jan 2023 18:33:49 -0800	[thread overview]
Message-ID: <20230131023354.1732677-10-kuba@kernel.org> (raw)
In-Reply-To: <20230131023354.1732677-1-kuba@kernel.org>

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: Jakub Kicinski <kuba@kernel.org>
---
 tools/net/ynl/cli.py     | 9 +++++----
 tools/net/ynl/lib/ynl.py | 6 ++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/net/ynl/cli.py b/tools/net/ynl/cli.py
index 5c4eb5a68514..05d1f4069ce1 100755
--- a/tools/net/ynl/cli.py
+++ b/tools/net/ynl/cli.py
@@ -32,10 +32,11 @@ from lib import YnlFamily
     if args.sleep:
         time.sleep(args.sleep)
 
-    if args.do or args.dump:
-        method = getattr(ynl, args.do if args.do else args.dump)
-
-        reply = method(attrs, dump=bool(args.dump))
+    if args.do:
+        reply = ynl.do(args.do, attrs)
+        pprint.PrettyPrinter().pprint(reply)
+    if args.dump:
+        reply = ynl.dump(args.dump, attrs)
         pprint.PrettyPrinter().pprint(reply)
 
     if args.ntf:
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 2ff3e6dbdbf6..1c7411ee04dc 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -520,3 +520,9 @@ genl_family_name_to_id = None
         if not dump and len(rsp) == 1:
             return rsp[0]
         return rsp
+
+    def do(self, method, vals):
+        return self._op(method, vals)
+
+    def dump(self, method, vals):
+        return self._op(method, vals, dump=True)
-- 
2.39.1


  parent reply	other threads:[~2023-01-31  2:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31  2:33 [PATCH net-next v2 00/14] tools: ynl: more docs and basic ethtool support Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 01/14] tools: ynl-gen: prevent do / dump reordering Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 02/14] tools: ynl: move the cli and netlink code around Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 03/14] tools: ynl: add an object hierarchy to represent parsed spec Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 04/14] tools: ynl: use the common YAML loading and validation code Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 05/14] tools: ynl: add support for types needed by ethtool Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 06/14] tools: ynl: support directional enum-model in CLI Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 07/14] tools: ynl: support multi-attr Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 08/14] tools: ynl: support pretty printing bad attribute names Jakub Kicinski
2023-01-31  2:33 ` Jakub Kicinski [this message]
2023-01-31  2:33 ` [PATCH net-next v2 10/14] tools: ynl: load jsonschema on demand Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 11/14] netlink: specs: finish up operation enum-models Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 12/14] netlink: specs: add partial specification for ethtool Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 13/14] docs: netlink: add a starting guide for working with specs Jakub Kicinski
2023-01-31  2:33 ` [PATCH net-next v2 14/14] tools: net: use python3 explicitly Jakub Kicinski
2023-02-01  4:40 ` [PATCH net-next v2 00/14] tools: ynl: more docs and basic ethtool support patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230131023354.1732677-10-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).