@@ -97,7 +97,7 @@ var Command = cli.Command{
9797 Flags : append ([]cli.Flag {
9898 cli.BoolFlag {
9999 Name : "rm" ,
100- Usage : "remove the container after running" ,
100+ Usage : "remove the container after running, cannot be used with --detach " ,
101101 },
102102 cli.BoolFlag {
103103 Name : "null-io" ,
@@ -109,7 +109,7 @@ var Command = cli.Command{
109109 },
110110 cli.BoolFlag {
111111 Name : "detach,d" ,
112- Usage : "detach from the task after it has started execution" ,
112+ Usage : "detach from the task after it has started execution, cannot be used with --rm " ,
113113 },
114114 cli.StringFlag {
115115 Name : "fifo-dir" ,
@@ -136,6 +136,7 @@ var Command = cli.Command{
136136 id string
137137 ref string
138138
139+ rm = context .Bool ("rm" )
139140 tty = context .Bool ("tty" )
140141 detach = context .Bool ("detach" )
141142 config = context .IsSet ("config" )
@@ -158,6 +159,10 @@ var Command = cli.Command{
158159 if id == "" {
159160 return errors .New ("container id must be provided" )
160161 }
162+ if rm && detach {
163+ return errors .New ("flags --detach and --rm cannot be specified together" )
164+ }
165+
161166 client , ctx , cancel , err := commands .NewClient (context )
162167 if err != nil {
163168 return err
@@ -167,7 +172,7 @@ var Command = cli.Command{
167172 if err != nil {
168173 return err
169174 }
170- if context . Bool ( "rm" ) && ! detach {
175+ if rm && ! detach {
171176 defer container .Delete (ctx , containerd .WithSnapshotCleanup )
172177 }
173178 var con console.Console
0 commit comments