Refactor query reading from file, update docs

Add support for @file syntax in more places.
This commit is contained in:
Gordian Schoenherr
2024-12-13 12:48:38 +09:00
parent 005114839a
commit 9691b0f518
11 changed files with 101 additions and 56 deletions
+2 -8
View File
@@ -29,12 +29,10 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
fetchMirror := false
ignoreSignatures := context.Config().GpgDisableVerify
var f string
context.Flags().Visit(func(flag *flag.Flag) {
switch flag.Name {
case "filter":
repo.Filter, err = getContent(flag.Value.String())
f = flag.Value.String()
repo.Filter = flag.Value.String()
case "filter-with-deps":
repo.FilterWithDeps = flag.Value.Get().(bool)
case "with-installer":
@@ -51,10 +49,6 @@ func aptlyMirrorEdit(cmd *commander.Command, args []string) error {
}
})
if repo.Filter != "" && err != nil {
return fmt.Errorf("unable to read package query from file %s: %w", f, err)
}
if repo.IsFlat() && repo.DownloadUdebs {
return fmt.Errorf("unable to edit: flat mirrors don't support udebs")
}
@@ -110,7 +104,7 @@ Example:
}
cmd.Flag.String("archive-url", "", "archive url is the root of archive")
cmd.Flag.String("filter", "", "filter packages in mirror")
AddStringOrFileFlag(&cmd.Flag, "filter", "", "filter packages in mirror, use '@file' to read filter from file or '@-' for stdin")
cmd.Flag.Bool("filter-with-deps", false, "when filtering, include dependencies of matching packages as well")
cmd.Flag.Bool("ignore-signatures", false, "disable verification of Release file signatures")
cmd.Flag.Bool("with-installer", false, "download additional not packaged installer files")