From 40b1b223d4561d652239d48bfd58beea9fd62c51 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Mon, 15 May 2023 13:41:37 +0000 Subject: [PATCH] feat: support to specify maximum amount of downloads --- distro.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/distro.go b/distro.go index 31a1807..ffa4b29 100644 --- a/distro.go +++ b/distro.go @@ -52,6 +52,8 @@ type DebianGetDebCmd struct { Regexp string `help:"match deb pkg names by regexp" default:".*"` IgnoreCached bool `help:"ignore packages found on remote mirror"` + + Max int `help:"do not download more than X" default:"100500"` } func (cmd DebianGetDebCmd) Run() (err error) { @@ -86,6 +88,10 @@ func (cmd DebianGetDebCmd) Run() (err error) { hasresults := false for _, pkg := range packages { + if cmd.Max <= 0 { + break + } + if cmd.IgnoreCached { log.Debug().Msgf("check cache for %s", pkg.Deb.Name) found, _ := cache.PackageURL(config.Debian, pkg.Deb.URL) @@ -116,6 +122,7 @@ func (cmd DebianGetDebCmd) Run() (err error) { } hasresults = true + cmd.Max-- } if !hasresults {