17778: update docs.
[arvados.git] / lib / deduplicationreport / command.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package deduplicationreport
6
7 import (
8         "io"
9
10         "git.arvados.org/arvados.git/sdk/go/ctxlog"
11         "github.com/sirupsen/logrus"
12 )
13
14 var Command command
15
16 type command struct{}
17
18 type NoPrefixFormatter struct{}
19
20 func (f *NoPrefixFormatter) Format(entry *logrus.Entry) ([]byte, error) {
21         return []byte(entry.Message + "\n"), nil
22 }
23
24 // RunCommand implements the subcommand "deduplication-report <collection> <collection> ..."
25 func (command) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
26         var err error
27         logger := ctxlog.New(stderr, "text", "info")
28         defer func() {
29                 if err != nil {
30                         logger.WithError(err).Error("fatal")
31                 }
32         }()
33
34         logger.SetFormatter(new(NoPrefixFormatter))
35
36         exitcode := report(prog, args, logger, stdout, stderr)
37
38         return exitcode
39 }