1/*
2Copyright (c) 2014-2017 VMware, Inc. All Rights Reserved.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package guest
18
19import (
20	"context"
21	"flag"
22
23	"github.com/vmware/govmomi/govc/cli"
24)
25
26type rm struct {
27	*GuestFlag
28}
29
30func init() {
31	cli.Register("guest.rm", &rm{})
32}
33
34func (cmd *rm) Register(ctx context.Context, f *flag.FlagSet) {
35	cmd.GuestFlag, ctx = newGuestFlag(ctx)
36	cmd.GuestFlag.Register(ctx, f)
37}
38
39func (cmd *rm) Process(ctx context.Context) error {
40	if err := cmd.GuestFlag.Process(ctx); err != nil {
41		return err
42	}
43	return nil
44}
45
46func (cmd *rm) Usage() string {
47	return "PATH"
48}
49
50func (cmd *rm) Description() string {
51	return `Remove file PATH in VM.
52
53Examples:
54  govc guest.rm -vm $name /tmp/foo.log`
55}
56
57func (cmd *rm) Run(ctx context.Context, f *flag.FlagSet) error {
58	m, err := cmd.FileManager()
59	if err != nil {
60		return err
61	}
62
63	return m.DeleteFile(ctx, cmd.Auth(), f.Arg(0))
64}
65