• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mvisonneau / go-ebsnvme / 6508556066

13 Oct 2023 12:59PM UTC coverage: 54.938% (+19.0%) from 35.897%
6508556066

push

github

mvisonneau
Released v0.2.0

89 of 162 relevant lines covered (54.94%)

1.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.0
/internal/cli/cli.go
1
package cli
2

3
import (
4
        "fmt"
5
        "os"
6

7
        "github.com/urfave/cli/v2"
8

9
        "github.com/mvisonneau/go-ebsnvme/internal/cli/flags"
10
        "github.com/mvisonneau/go-ebsnvme/internal/cli/output"
11
        "github.com/mvisonneau/go-ebsnvme/pkg/ebsnvme"
12
)
13

14
const (
15
        usageText = "go-ebsnvme [opts] <block_device>"
16
)
17

18
// Run handles the instantiation of the CLI application.
19
func Run(version string, args []string) {
1✔
20
        err := NewApp(version).Run(args)
1✔
21
        if err != nil {
1✔
22
                fmt.Println(err)
×
23
                os.Exit(1)
×
24
        }
×
25
}
26

27
// NewApp configures the CLI application.
28
func NewApp(version string) (app *cli.App) {
2✔
29
        app = cli.NewApp()
2✔
30
        app.Name = "go-ebsnvme"
2✔
31
        app.Version = version
2✔
32
        app.Usage = "Find details about currently attached AWS EBS NVMe volumes"
2✔
33
        app.UsageText = usageText
2✔
34
        app.EnableBashCompletion = true
2✔
35

2✔
36
        app.Flags = cli.FlagsByName{
2✔
37
                flags.OutputType,
2✔
38
                flags.OutputField,
2✔
39
        }
2✔
40

2✔
41
        app.Action = func(ctx *cli.Context) (err error) {
2✔
42
                var outputType output.Type
×
43
                if outputType, err = output.ParseTypeFromString(flags.OutputType.Get(ctx)); err != nil {
×
44
                        return
×
45
                }
×
46

47
                var outputFields output.Fields
×
48
                if outputFields, err = output.ParseFieldsFromStringSlice(flags.OutputField.Get(ctx)); err != nil {
×
49
                        return
×
50
                }
×
51

52
                var device ebsnvme.Device
×
53
                if device, err = ebsnvme.ScanDevice(ctx.Args().First()); err != nil {
×
54
                        return
×
55
                }
×
56

57
                fmt.Println(output.FormatDeviceDetails(
×
58
                        device,
×
59
                        outputType,
×
60
                        outputFields,
×
61
                ))
×
62

×
63
                return
×
64
        }
65

66
        return
2✔
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc