From 860490af5db945c37e9e6e24c019899fbe739dc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Graber?= Date: Fri, 7 Mar 2014 15:01:54 -0500 Subject: [PATCH] lxc-ls: Update help message to include fields MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Instead of maintaining hardcoded lists, point everyone to --help and have the current list of valid and default fields printed there. Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- doc/lxc-ls.sgml.in | 3 +-- src/lxc/lxc-ls.in | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/lxc-ls.sgml.in b/doc/lxc-ls.sgml.in index 37e356c47..1c40d33de 100644 --- a/doc/lxc-ls.sgml.in +++ b/doc/lxc-ls.sgml.in @@ -145,8 +145,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Comma separate list of column to show in the fancy output. - Valid values are: name, state, ipv4, ipv6 and pid - Default is: name,state,ipv4,ipv6 + The list of accepted and default fields is listed in --help. diff --git a/src/lxc/lxc-ls.in b/src/lxc/lxc-ls.in index 0f8139115..7e35ab26e 100755 --- a/src/lxc/lxc-ls.in +++ b/src/lxc/lxc-ls.in @@ -104,10 +104,16 @@ def get_root_path(path): # Constants FIELDS = ("name", "state", "ipv4", "ipv6", "autostart", "pid", "memory", "ram", "swap") +DEFAULT_FIELDS = ("name", "state", "ipv4", "ipv6", "autostart") # Begin parsing the command line parser = argparse.ArgumentParser(description=_("LXC: List containers"), - formatter_class=argparse.RawTextHelpFormatter) + formatter_class=argparse.RawTextHelpFormatter, + epilog=_("""Valid fancy-format fields: + %s + +Default fancy-format fields: + %s\n""" % (", ".join(FIELDS), ", ".join(DEFAULT_FIELDS)))) parser.add_argument("-1", dest="one", action="store_true", help=_("list one container per line (default when piped)")) @@ -132,7 +138,7 @@ parser.add_argument("-f", "--fancy", action="store_true", help=_("use fancy output")) parser.add_argument("-F", "--fancy-format", type=str, - default="name,state,ipv4,ipv6,autostart", + default=",".join(DEFAULT_FIELDS), help=_("comma separated list of fields to show")) parser.add_argument("--nesting", dest="nesting", action="store_true", -- 2.47.3