[lxc-devel] [lxd/master] lxc/init: Fix usage with no args

stgraber on Github lxc-bot at linuxcontainers.org
Tue Sep 3 13:56:14 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190903/a64917eb/attachment.bin>
-------------- next part --------------
From 4ca7b2b0035ae77849a438a36c84b2d0f8628d14 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 3 Sep 2019 09:55:51 -0400
Subject: [PATCH] lxc/init: Fix usage with no args
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/init.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lxc/init.go b/lxc/init.go
index 9472e68e95..d3022b141f 100644
--- a/lxc/init.go
+++ b/lxc/init.go
@@ -58,6 +58,11 @@ func (c *cmdInit) Run(cmd *cobra.Command, args []string) error {
 		return err
 	}
 
+	if len(args) == 0 && !c.flagEmpty {
+		cmd.Usage()
+		return nil
+	}
+
 	_, _, err = c.create(c.global.conf, args)
 	return err
 }


More information about the lxc-devel mailing list