@@ -2,6 +2,7 @@ package ads
22
33import (
44 "bufio"
5+ "context"
56 "encoding/base64"
67 "errors"
78 "fmt"
@@ -14,7 +15,7 @@ import (
1415 "github.com/ipni/ipni-cli/pkg/adpub"
1516 "github.com/libp2p/go-libp2p/core/peer"
1617 "github.com/mattn/go-isatty"
17- "github.com/urfave/cli/v2 "
18+ "github.com/urfave/cli/v3 "
1819)
1920
2021var adsGetSubCmd = & cli.Command {
@@ -68,14 +69,14 @@ var adsGetFlags = []cli.Flag{
6869 topicFlag ,
6970}
7071
71- func adsGetAction (cctx * cli.Context ) error {
72- addrInfo , err := peer .AddrInfoFromString (cctx .String ("addr-info" ))
72+ func adsGetAction (ctx context. Context , cmd * cli.Command ) error {
73+ addrInfo , err := peer .AddrInfoFromString (cmd .String ("addr-info" ))
7374 if err != nil {
7475 return fmt .Errorf ("bad pub-addr-info: %w" , err )
7576 }
7677
7778 var adCids []cid.Cid
78- cidArgs := cctx .StringSlice ("cid" )
79+ cidArgs := cmd .StringSlice ("cid" )
7980 if len (cidArgs ) != 0 {
8081 seen := make (map [string ]struct {}, len (cidArgs ))
8182 adCids = make ([]cid.Cid , 0 , len (cidArgs ))
@@ -91,7 +92,7 @@ func adsGetAction(cctx *cli.Context) error {
9192 adCids = append (adCids , cid )
9293 }
9394 }
94- if cctx .Bool ("head" ) {
95+ if cmd .Bool ("head" ) {
9596 // Fetch latest advertisement
9697 adCids = append (adCids , cid .Undef )
9798 }
@@ -125,17 +126,17 @@ func adsGetAction(cctx *cli.Context) error {
125126 }
126127
127128 pubClient , err := adpub .NewClient (* addrInfo ,
128- adpub .WithTopicName (cctx .String ("topic" )),
129- adpub .WithEntriesDepthLimit (cctx .Int64 ("entries-depth-limit" )),
130- adpub .WithHttpTimeout (cctx .Duration ("timeout" )))
129+ adpub .WithTopicName (cmd .String ("topic" )),
130+ adpub .WithEntriesDepthLimit (cmd .Int64 ("entries-depth-limit" )),
131+ adpub .WithHttpTimeout (cmd .Duration ("timeout" )))
131132 if err != nil {
132133 return err
133134 }
134135
135136 for _ , adCid := range adCids {
136137 fmt .Println ()
137138
138- ad , err := pubClient .GetAdvertisement (cctx . Context , adCid )
139+ ad , err := pubClient .GetAdvertisement (ctx , adCid )
139140 if err != nil {
140141 if ad == nil {
141142 if errors .Is (err , adpub .ErrContentNotFound ) {
@@ -223,12 +224,12 @@ func adsGetAction(cctx *cli.Context) error {
223224 continue
224225 }
225226
226- if cctx .Bool ("skip-entries" ) {
227+ if cmd .Bool ("skip-entries" ) {
227228 continue
228229 }
229230
230231 // Sync entries if not a removal advertisement and has entries.
231- err = pubClient .SyncEntriesWithRetry (cctx . Context , ad .Entries .Root ())
232+ err = pubClient .SyncEntriesWithRetry (ctx , ad .Entries .Root ())
232233 if err != nil {
233234 fmt .Fprintf (os .Stderr , "⚠️ Failed to sync entries for advertisement %s: %s\n " , ad .ID , err )
234235 continue
@@ -244,7 +245,7 @@ func adsGetAction(cctx *cli.Context) error {
244245 entriesOutput = "⚠️ Note: More entries were available but not synced due to the configured entries recursion limit or error during traversal."
245246 }
246247
247- if cctx .Bool ("print-entries" ) {
248+ if cmd .Bool ("print-entries" ) {
248249 for _ , mh := range entries {
249250 fmt .Printf (" %s\n " , mh .B58String ())
250251 }
0 commit comments