diff --git a/pkg/cli/generate_registry.go b/pkg/cli/generate_registry.go index 36748b3c1..908f0291c 100644 --- a/pkg/cli/generate_registry.go +++ b/pkg/cli/generate_registry.go @@ -59,6 +59,25 @@ If --out-testdata is set, aqua inserts testdata into the specified file. e.g. $ aqua gr --out-testdata testdata.yaml suzuki-shunsuke/tfcmt + +If -cmd is set, aqua sets files. + +e.g. + +$ aqua gr -cmd gh cli/cli + + files: + - name: gh + +You can specify multiple commands with commas ",". + +e.g. + +$ aqua gr -cmd age,age-keygen FiloSottile/age + + files: + - name: age + - name: age-keygen ` func (r *Runner) newGenerateRegistryCommand() *cli.Command { @@ -79,6 +98,10 @@ func (r *Runner) newGenerateRegistryCommand() *cli.Command { Name: "out-testdata", Usage: "A file path where the testdata is outputted", }, + &cli.StringFlag{ + Name: "cmd", + Usage: "A list of commands joined with single quotes ','", + }, &cli.BoolFlag{ Name: "deep", Usage: "Resolve version_overrides", diff --git a/pkg/cli/runner.go b/pkg/cli/runner.go index 72eeddbbc..7945bef7f 100644 --- a/pkg/cli/runner.go +++ b/pkg/cli/runner.go @@ -54,6 +54,9 @@ func (r *Runner) setParam(c *cli.Context, commandName string, param *config.Para param.Prune = c.Bool("prune") param.SelectVersion = c.Bool("select-version") param.File = c.String("f") + if cmd := c.String("cmd"); cmd != "" { + param.Commands = strings.Split(cmd, ",") + } param.LogColor = os.Getenv("AQUA_LOG_COLOR") param.AQUAVersion = r.LDFlags.Version param.AquaCommitHash = r.LDFlags.Commit diff --git a/pkg/config/package.go b/pkg/config/package.go index 746c6c620..6a3092e7a 100644 --- a/pkg/config/package.go +++ b/pkg/config/package.go @@ -269,6 +269,7 @@ type Param struct { OnlyPackage bool OnlyRegistry bool PolicyConfigFilePaths []string + Commands []string } func appendExt(s, format string) string { diff --git a/pkg/controller/generate-registry/generate.go b/pkg/controller/generate-registry/generate.go index 4d7146159..44bfb6606 100644 --- a/pkg/controller/generate-registry/generate.go +++ b/pkg/controller/generate-registry/generate.go @@ -56,6 +56,15 @@ func (c *Controller) GenerateRegistry(ctx context.Context, param *config.Param, func (c *Controller) genRegistry(ctx context.Context, param *config.Param, logE *logrus.Entry, pkgName string) error { pkgInfo, versions := c.getPackageInfo(ctx, logE, pkgName, param.Deep) + if len(param.Commands) != 0 { + files := make([]*registry.File, len(param.Commands)) + for i, cmd := range param.Commands { + files[i] = ®istry.File{ + Name: cmd, + } + } + pkgInfo.Files = files + } if param.OutTestData != "" { if err := c.testdataOutputter.Output(&output.Param{ List: listPkgsFromVersions(pkgName, versions),