refactor!: migrate to urfave/cli v1

Better flexible flags handling.
This commit is contained in:
2022-01-18 14:13:20 +01:00
parent c6db9ee355
commit 0e688f1407
48 changed files with 502 additions and 405 deletions

View File

@ -1,6 +1,7 @@
package record
import (
"context"
"fmt"
"strconv"
@ -11,16 +12,18 @@ import (
"github.com/libdns/gandi"
"github.com/libdns/libdns"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"github.com/urfave/cli"
)
// RecordNewCommand creates a new domain name record.
var RecordNewCommand = &cli.Command{
var RecordNewCommand = cli.Command{
Name: "new",
Usage: "Create a new domain record",
Aliases: []string{"n"},
ArgsUsage: "<zone>",
Flags: []cli.Flag{
internal.DebugFlag,
internal.NoInputFlag,
internal.DNSProviderFlag,
internal.DNSTypeFlag,
internal.DNSNameFlag,
@ -29,6 +32,7 @@ var RecordNewCommand = &cli.Command{
internal.DNSPriorityFlag,
internal.AutoDNSRecordFlag,
},
Before: internal.SubCommandBefore,
Description: `
This command creates a new domain name record for a specific zone.
@ -118,7 +122,7 @@ You may also invoke this command in "wizard" mode and be prompted for input
record.Priority = internal.DNSPriority
}
records, err := provider.GetRecords(c.Context, zone)
records, err := provider.GetRecords(context.Background(), zone)
if err != nil {
logrus.Fatal(err)
}
@ -132,7 +136,7 @@ You may also invoke this command in "wizard" mode and be prompted for input
}
createdRecords, err := provider.SetRecords(
c.Context,
context.Background(),
zone,
[]libdns.Record{record},
)
@ -196,7 +200,7 @@ func autoConfigure(c *cli.Context, provider *gandi.Provider, zone, ipv4 string)
table := formatter.CreateTable(tableCol)
for _, record := range records {
existingRecords, err := provider.GetRecords(c.Context, zone)
existingRecords, err := provider.GetRecords(context.Background(), zone)
if err != nil {
return err
}
@ -216,7 +220,7 @@ func autoConfigure(c *cli.Context, provider *gandi.Provider, zone, ipv4 string)
}
createdRecords, err := provider.SetRecords(
c.Context,
context.Background(),
zone,
[]libdns.Record{record},
)