mirror of
https://github.com/kopia/kopia.git
synced 2025-12-23 22:57:50 -05:00
* Update display on repository summary * Apply throughout app * Situate units_test * Update Command Line documentation * Envar cleanup * Rename to BytesString * Restore envar string available for test * Remove extraneous empty check and restore UIPreferences field for frontend * PR: config bool cleanup and missed `BaseEnv`s * Fix lint and test
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/internal/units"
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
type commandLogsList struct {
|
|
out textOutput
|
|
|
|
crit logSelectionCriteria
|
|
}
|
|
|
|
func (c *commandLogsList) setup(svc appServices, parent commandParent) {
|
|
cmd := parent.Command("list", "List logs.").Alias("ls")
|
|
|
|
cmd.Action(svc.directRepositoryReadAction(c.run))
|
|
|
|
c.out.setup(svc)
|
|
c.crit.setup(cmd)
|
|
}
|
|
|
|
func (c *commandLogsList) run(ctx context.Context, rep repo.DirectRepository) error {
|
|
allSessions0, err := getLogSessions(ctx, rep.BlobReader())
|
|
if err != nil {
|
|
return errors.Wrap(err, "error getting log sessions")
|
|
}
|
|
|
|
allSessions := c.crit.filterLogSessions(allSessions0)
|
|
|
|
if len(allSessions) < len(allSessions0) {
|
|
defer log(ctx).Infof("NOTE: Listed %v/%v log sessions, pass --all to show all.", len(allSessions), len(allSessions0))
|
|
}
|
|
|
|
// output sessions
|
|
for _, s := range allSessions {
|
|
c.out.printStdout(
|
|
"%v %v %v %v %v\n", s.id,
|
|
formatTimestamp(s.startTime),
|
|
s.endTime.Sub(s.startTime),
|
|
units.BytesString(s.totalSize),
|
|
len(s.segments),
|
|
)
|
|
}
|
|
|
|
return nil
|
|
}
|