-
Notifications
You must be signed in to change notification settings - Fork 46
/
generate_help.go
58 lines (45 loc) · 1.46 KB
/
generate_help.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package cli
import (
"github.com/hashicorp/nomad-pack/internal/pkg/flag"
"github.com/posener/complete"
)
// GenerateHelpCommand exists solely to provide top level help for the registry
// set of subcommands.
type GenerateHelpCommand struct {
*baseCommand
}
func (c *GenerateHelpCommand) Run(args []string) int {
c.cmdKey = "generate"
// Initialize. If we fail, we just exit since Init handles the UI.
if err := c.Init(
WithNoArgs(args),
WithNoConfig(),
WithClient(false),
); err != nil {
c.ui.Info("The generate command requires one of the following subcommands: pack, registry, var-file.")
return 1
}
c.ui.Info("The generate command requires one of the following subcommands: pack, registry, var-file.")
return 0
}
func (c *GenerateHelpCommand) Flags() *flag.Sets {
return c.flagSet(0, nil)
}
func (c *GenerateHelpCommand) AutocompleteArgs() complete.Predictor {
return complete.PredictNothing
}
func (c *GenerateHelpCommand) AutocompleteFlags() complete.Flags {
return c.Flags().Completions()
}
func (c *GenerateHelpCommand) Synopsis() string {
return "Generate a sample nomad-pack registry, pack, or variable overrides file for a pack."
}
func (c *GenerateHelpCommand) Help() string {
return formatHelp(`
Usage: nomad-pack generate <subcommand> [options]
Generate a sample nomad-pack registry, pack, or variable overrides file for a
pack.
` + c.GetExample() + c.Flags().Help())
}