You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by kl...@apache.org on 2017/05/29 22:03:03 UTC

mesos git commit: Added 'mesos config show' command to the new Mesos CLI.

Repository: mesos
Updated Branches:
  refs/heads/master 8ea469909 -> 2dada1832


Added 'mesos config show' command to the new Mesos CLI.

This command displays the contents of the user-defined config.toml file.

Review: https://reviews.apache.org/r/58137/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2dada183
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2dada183
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2dada183

Branch: refs/heads/master
Commit: 2dada1832081bf3c72c52d92a3537bb7ef72e077
Parents: 8ea4699
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Mon May 29 14:54:52 2017 -0700
Committer: Kevin Klues <kl...@gmail.com>
Committed: Mon May 29 15:00:25 2017 -0700

----------------------------------------------------------------------
 src/cli_new/lib/cli/plugins/config/main.py | 28 +++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/2dada183/src/cli_new/lib/cli/plugins/config/main.py
----------------------------------------------------------------------
diff --git a/src/cli_new/lib/cli/plugins/config/main.py b/src/cli_new/lib/cli/plugins/config/main.py
index 6e19e5c..41bdb60 100644
--- a/src/cli_new/lib/cli/plugins/config/main.py
+++ b/src/cli_new/lib/cli/plugins/config/main.py
@@ -18,10 +18,12 @@
 The config plugin.
 """
 
+import os
 import sys
 
 import cli
 
+from cli.exceptions import CLIException
 from cli.plugins import PluginBase
 from cli.util import Table
 
@@ -45,6 +47,12 @@ class Config(PluginBase):
             "flags": {},
             "short_help": "Print the plugins that can be used.",
             "long_help": "Print the plugins that can be used."
+        },
+        "show": {
+            "arguments": [],
+            "flags": {},
+            "short_help": "Show the contents of the configuration file.",
+            "long_help": "Show the contents of the configuration file."
         }
     }
 
@@ -68,3 +76,23 @@ class Config(PluginBase):
                 cli.util.get_module(plugins, plugin).SHORT_HELP
             ])
         sys.stdout.write("{}\n".format(plugins_table))
+
+    def show(self, argv):
+        """
+        Show the contents of the configuration file.
+        """
+        # pylint: disable=unused-argument
+        config_file = self.config.path
+        if not os.path.isfile(config_file):
+            raise CLIException("Unable to show the config file,"
+                               " '{path}' does not exist"
+                               .format(path=config_file))
+
+        with open(config_file, 'r') as stream:
+            try:
+                sys.stdout.write("{stream}\n"
+                                 .format(stream=stream.read().rstrip()))
+            except Exception as exception:
+                raise CLIException("Unable to read config file '{path}':"
+                                   " {error}"
+                                   .format(path=config_file, error=exception))