cmds

package
v0.0.0-...-4b5464e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AwsCommand = &cli.Command{
	Name:        "aws",
	Description: "Open hashicorp/aws's docs",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "type",
			Value: "resources",
			Usage: "resources or data-sources. default is resources.",
		},
	},
	Action: func(cCtx *cli.Context) error {
		tfType := cCtx.String("type")
		var list []string
		switch tfType {
		case "resources":
			list = tfdocsfinder.AwsResources
		case "data-sources":
			list = tfdocsfinder.AwsDataSources
		default:
			return cli.Exit(fmt.Errorf("invalid type: %s", tfType), 1)
		}
		idx, err := fuzzyfinder.Find(list, func(i int) string {
			return list[i]
		})
		if err != nil {
			return nil
		}
		fmt.Println(list[idx])
		url := fmt.Sprintf("https://registry.terraform.io/providers/hashicorp/aws/latest/docs/%s/%s", tfType, strings.TrimPrefix(list[idx], "aws_"))
		if err := openBrowser(url); err != nil {
			return cli.Exit(err, 1)
		}
		return nil
	},
}
View Source
var GitHubCommand = &cli.Command{
	Name:        "github",
	Description: "Open integrations/github's docs",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "type",
			Value: "resources",
			Usage: "resources or data-sources. default is resources.",
		},
	},
	Action: func(cCtx *cli.Context) error {
		tfType := cCtx.String("type")
		var list []string
		switch tfType {
		case "resources":
			list = tfdocsfinder.GitHubResources
		case "data-sources":
			list = tfdocsfinder.GitHubDataSources
		default:
			return cli.Exit(fmt.Errorf("invalid type: %s", tfType), 1)
		}
		idx, err := fuzzyfinder.Find(list, func(i int) string {
			return list[i]
		})
		if err != nil {
			return nil
		}
		fmt.Println(list[idx])
		url := fmt.Sprintf("https://registry.terraform.io/providers/integrations/github/latest/docs/%s/%s", tfType, strings.TrimPrefix(list[idx], "github_"))
		if err := openBrowser(url); err != nil {
			return cli.Exit(err, 1)
		}
		return nil
	},
}
View Source
var GoogleCommand = &cli.Command{
	Name:        "google",
	Description: "Open hashicorp/google's docs",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:  "type",
			Value: "resources",
			Usage: "resources or data-sources. default is resources.",
		},
	},
	Action: func(cCtx *cli.Context) error {
		tfType := cCtx.String("type")
		var list []string
		switch tfType {
		case "resources":
			list = tfdocsfinder.GoogleResources
		case "data-sources":
			list = tfdocsfinder.GoogleDataSources
		default:
			return cli.Exit(fmt.Errorf("invalid type: %s", tfType), 1)
		}
		idx, err := fuzzyfinder.Find(list, func(i int) string {
			return list[i]
		})
		if err != nil {
			return nil
		}
		fmt.Println(list[idx])
		url := fmt.Sprintf("https://registry.terraform.io/providers/hashicorp/google/latest/docs/%s/%s", tfType, strings.TrimPrefix(list[idx], "google_"))
		if err := openBrowser(url); err != nil {
			return cli.Exit(err, 1)
		}
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL