Soft Patch Panel
 help / color / mirror / Atom feed
From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 1/6] cli: add env command
Date: Fri, 20 Dec 2019 16:40:58 +0900	[thread overview]
Message-ID: <20191220074103.14065-2-yasufum.o@gmail.com> (raw)
In-Reply-To: <20191220074103.14065-1-yasufum.o@gmail.com>

From: Yasufumi Ogawa <yasufum.o@gmail.com>

Add `env` command for displaying environmental variables. It displays
env variables starts with given keyword, or all variables if it is not
given. It is mainly used for finding variables related to SPP.

  # show variables starts with `SPP`
  spp > env SPP
  SPP_CTL_IP: 127.0.0.1
  SPP_FILE_PREFIX: spp

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 src/cli/commands/help_msg.py | 10 ++++++++++
 src/cli/shell.py             | 11 +++++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/cli/commands/help_msg.py b/src/cli/commands/help_msg.py
index f303547..4cf2a1f 100644
--- a/src/cli/commands/help_msg.py
+++ b/src/cli/commands/help_msg.py
@@ -8,6 +8,16 @@ cmds = {
         spp > status
         """,
 
+        'env':
+        """Show environmental variables.
+
+        # show all env varibles.
+        spp > env
+
+        # show env varibles starts with `SPP`.
+        spp > env SPP
+        """,
+
         'record':
         """Save commands as a recipe file.
 
diff --git a/src/cli/shell.py b/src/cli/shell.py
index 0de6176..cfc343c 100644
--- a/src/cli/shell.py
+++ b/src/cli/shell.py
@@ -317,6 +317,17 @@ class Shell(cmd.Cmd, object):
         """Print help message of status command."""
         print(help_msg.cmds['status'])
 
+    def do_env(self, key):
+        """Display environmental variables."""
+
+        for k, v in sorted(os.environ.items()):
+            if k.startswith(key):
+                print("{}: {}".format(k, v))
+
+    def help_env(self):
+        """Print help message of env command."""
+        print(help_msg.cmds['env'])
+
     def do_pri(self, command):
         """Send a command to primary process."""
 
-- 
2.17.1


  reply	other threads:[~2019-12-20  7:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20  7:40 [spp] [PATCH 0/6] Run SPP with --file-prefix option yasufum.o
2019-12-20  7:40 ` yasufum.o [this message]
2019-12-20  7:40 ` [spp] [PATCH 2/6] cli: add file prefix opt for launch cmd yasufum.o
2019-12-20  7:41 ` [spp] [PATCH 3/6] bin: add SPP_FILE_PREFIX env variable yasufum.o
2019-12-20  7:41 ` [spp] [PATCH 4/6] readme: update example of config.sh yasufum.o
2019-12-20  7:41 ` [spp] [PATCH 5/6] docs: add desc for env command yasufum.o
2019-12-20  7:41 ` [spp] [PATCH 6/6] docs: add file prefix option in usecases yasufum.o

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=20191220074103.14065-2-yasufum.o@gmail.com \
    --to=yasufum.o@gmail.com \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /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).