1/*
2Copyright (c) 2016 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 account
18
19import (
20	"context"
21	"flag"
22
23	"github.com/vmware/govmomi/govc/cli"
24)
25
26type update struct {
27	*AccountFlag
28}
29
30func init() {
31	cli.Register("host.account.update", &update{})
32}
33
34func (cmd *update) Register(ctx context.Context, f *flag.FlagSet) {
35	cmd.AccountFlag, ctx = newAccountFlag(ctx)
36	cmd.AccountFlag.Register(ctx, f)
37}
38
39func (cmd *update) Description() string {
40	return `Update local account on HOST.
41
42Examples:
43  govc host.account.update -id root -password password-for-esx60`
44}
45
46func (cmd *update) Process(ctx context.Context) error {
47	if err := cmd.AccountFlag.Process(ctx); err != nil {
48		return err
49	}
50	return nil
51}
52
53func (cmd *update) Run(ctx context.Context, f *flag.FlagSet) error {
54	m, err := cmd.AccountFlag.HostAccountManager(ctx)
55	if err != nil {
56		return err
57	}
58	return m.Update(ctx, &cmd.HostAccountSpec)
59}
60