From: Stéphane Graber Date: Fri, 7 Mar 2014 20:01:54 +0000 (-0500) Subject: lxc-ls: Update help message to include fields X-Git-Tag: lxc-1.1.0.alpha1~228 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=860490af5db945c37e9e6e24c019899fbe739dc5;p=thirdparty%2Flxc.git lxc-ls: Update help message to include fields 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 --- 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",