Skip to content

Commit

Permalink
Add manifest-dependencies-file flag
Browse files Browse the repository at this point in the history
  • Loading branch information
PapaCharlie committed Nov 12, 2024
1 parent 994ceb0 commit fdb9ace
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion v2/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@ func CodeGenerator(jar []byte) *cobra.Command {
var outputDir string
cmd.Flags().StringVarP(&outputDir, "output-dir", "o", ".", "The directory in which to output the generated files")

const manifestDependenciesFlag = "manifest-dependencies"
var manifestDependencies []string
cmd.Flags().StringSliceVarP(&manifestDependencies, "manifest-dependencies", "m", nil,
cmd.Flags().StringSliceVarP(&manifestDependencies, manifestDependenciesFlag, "m", nil,
`Files or directories that may contain other "`+utils.ManifestFile+`" manifest files that this manifest may `+
`depend on. Note that this may simply be "$GOPATH" or the "vendor" directory after "go mod vendor" is run.`)

var manifestDependenciesFile string
const manifestDependenciesFileFlag = manifestDependenciesFlag + "-file"
cmd.Flags().StringVar(&manifestDependenciesFile, manifestDependenciesFileFlag, "",
"If specified, each line in the file will be treated as if it was provided via --"+manifestDependenciesFlag)

var generateWithPackageRoot bool
cmd.Flags().BoolVar(&generateWithPackageRoot, "generate-with-package-root", false,
"If specified, the generated files will be generated with the package root directory structure.")
Expand Down Expand Up @@ -133,6 +139,14 @@ Inputs can be directories, files or JARs`)
jarParams.Inputs = dedupe(append(jarParams.Inputs, files...))
}

if cmd.Flags().Changed(manifestDependenciesFileFlag) {
files, err := readFileLines(manifestDependenciesFile)
if err != nil {
return err
}
manifestDependencies = dedupe(append(manifestDependencies, files...))
}

return nil
}

Expand Down

0 comments on commit fdb9ace

Please sign in to comment.