Merge pull request #5259 from filcloud/verbose-transfer

add verbose for list transfers
This commit is contained in:
Łukasz Magiera 2021-01-06 17:24:13 +01:00 committed by GitHub
commit cf299b39b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 11 deletions

View File

@ -1943,6 +1943,11 @@ var clientListTransfers = &cli.Command{
Name: "list-transfers", Name: "list-transfers",
Usage: "List ongoing data transfers for deals", Usage: "List ongoing data transfers for deals",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
Usage: "print verbose transfer details",
},
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Usage: "use color in display output", Usage: "use color in display output",
@ -1974,6 +1979,7 @@ var clientListTransfers = &cli.Command{
return err return err
} }
verbose := cctx.Bool("verbose")
completed := cctx.Bool("completed") completed := cctx.Bool("completed")
color := cctx.Bool("color") color := cctx.Bool("color")
watch := cctx.Bool("watch") watch := cctx.Bool("watch")
@ -1989,7 +1995,7 @@ var clientListTransfers = &cli.Command{
tm.MoveCursor(1, 1) tm.MoveCursor(1, 1)
OutputDataTransferChannels(tm.Screen, channels, completed, color, showFailed) OutputDataTransferChannels(tm.Screen, channels, verbose, completed, color, showFailed)
tm.Flush() tm.Flush()
@ -2014,13 +2020,13 @@ var clientListTransfers = &cli.Command{
} }
} }
} }
OutputDataTransferChannels(os.Stdout, channels, completed, color, showFailed) OutputDataTransferChannels(os.Stdout, channels, verbose, completed, color, showFailed)
return nil return nil
}, },
} }
// OutputDataTransferChannels generates table output for a list of channels // OutputDataTransferChannels generates table output for a list of channels
func OutputDataTransferChannels(out io.Writer, channels []lapi.DataTransferChannel, completed bool, color bool, showFailed bool) { func OutputDataTransferChannels(out io.Writer, channels []lapi.DataTransferChannel, verbose, completed, color, showFailed bool) {
sort.Slice(channels, func(i, j int) bool { sort.Slice(channels, func(i, j int) bool {
return channels[i].TransferID < channels[j].TransferID return channels[i].TransferID < channels[j].TransferID
}) })
@ -2050,7 +2056,7 @@ func OutputDataTransferChannels(out io.Writer, channels []lapi.DataTransferChann
tablewriter.Col("Voucher"), tablewriter.Col("Voucher"),
tablewriter.NewLineCol("Message")) tablewriter.NewLineCol("Message"))
for _, channel := range sendingChannels { for _, channel := range sendingChannels {
w.Write(toChannelOutput(color, "Sending To", channel)) w.Write(toChannelOutput(color, "Sending To", channel, verbose))
} }
w.Flush(out) //nolint:errcheck w.Flush(out) //nolint:errcheck
@ -2064,7 +2070,7 @@ func OutputDataTransferChannels(out io.Writer, channels []lapi.DataTransferChann
tablewriter.Col("Voucher"), tablewriter.Col("Voucher"),
tablewriter.NewLineCol("Message")) tablewriter.NewLineCol("Message"))
for _, channel := range receivingChannels { for _, channel := range receivingChannels {
w.Write(toChannelOutput(color, "Receiving From", channel)) w.Write(toChannelOutput(color, "Receiving From", channel, verbose))
} }
w.Flush(out) //nolint:errcheck w.Flush(out) //nolint:errcheck
} }
@ -2085,9 +2091,13 @@ func channelStatusString(useColor bool, status datatransfer.Status) string {
} }
} }
func toChannelOutput(useColor bool, otherPartyColumn string, channel lapi.DataTransferChannel) map[string]interface{} { func toChannelOutput(useColor bool, otherPartyColumn string, channel lapi.DataTransferChannel, verbose bool) map[string]interface{} {
rootCid := ellipsis(channel.BaseCID.String(), 8) rootCid := channel.BaseCID.String()
otherParty := ellipsis(channel.OtherPeer.String(), 8) otherParty := channel.OtherPeer.String()
if !verbose {
rootCid = ellipsis(rootCid, 8)
otherParty = ellipsis(otherParty, 8)
}
initiated := "N" initiated := "N"
if channel.IsInitiator { if channel.IsInitiator {
@ -2095,7 +2105,7 @@ func toChannelOutput(useColor bool, otherPartyColumn string, channel lapi.DataTr
} }
voucher := channel.Voucher voucher := channel.Voucher
if len(voucher) > 40 { if len(voucher) > 40 && !verbose {
voucher = ellipsis(voucher, 37) voucher = ellipsis(voucher, 37)
} }

View File

@ -744,6 +744,11 @@ var transfersListCmd = &cli.Command{
Name: "list", Name: "list",
Usage: "List ongoing data transfers for this miner", Usage: "List ongoing data transfers for this miner",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
Usage: "print verbose transfer details",
},
&cli.BoolFlag{ &cli.BoolFlag{
Name: "color", Name: "color",
Usage: "use color in display output", Usage: "use color in display output",
@ -775,6 +780,7 @@ var transfersListCmd = &cli.Command{
return err return err
} }
verbose := cctx.Bool("verbose")
completed := cctx.Bool("completed") completed := cctx.Bool("completed")
color := cctx.Bool("color") color := cctx.Bool("color")
watch := cctx.Bool("watch") watch := cctx.Bool("watch")
@ -790,7 +796,7 @@ var transfersListCmd = &cli.Command{
tm.MoveCursor(1, 1) tm.MoveCursor(1, 1)
lcli.OutputDataTransferChannels(tm.Screen, channels, completed, color, showFailed) lcli.OutputDataTransferChannels(tm.Screen, channels, verbose, completed, color, showFailed)
tm.Flush() tm.Flush()
@ -815,7 +821,7 @@ var transfersListCmd = &cli.Command{
} }
} }
} }
lcli.OutputDataTransferChannels(os.Stdout, channels, completed, color, showFailed) lcli.OutputDataTransferChannels(os.Stdout, channels, verbose, completed, color, showFailed)
return nil return nil
}, },
} }