Commit 860490af by Stéphane Graber

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: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent e582991f
......@@ -145,8 +145,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
......
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment