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

heathcliff26 / go-wol / 14551968200

19 Apr 2025 06:53PM UTC coverage: 85.714% (+0.5%) from 85.169%
14551968200

push

github

heathcliff26
api: Implement hosts endpoint

Implement functions for adding/removing hosts.
Fix an error where storage would allow any string to be added as a new MAC.

Signed-off-by: Heathcliff <heathcliff@heathcliff.eu>

34 of 41 new or added lines in 3 files covered. (82.93%)

1 existing line in 1 file now uncovered.

618 of 721 relevant lines covered (85.71%)

31.64 hits per line

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

27.03
/pkg/server/cmd.go
1
package server
2

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

7
        "github.com/heathcliff26/go-wol/pkg/server/config"
8
        "github.com/spf13/cobra"
9
)
10

11
const (
12
        flagNameConfig   = "config"
13
        flagNameLogLevel = "log"
14
        flagNameEnv      = "env"
15
)
16

17
func NewCommand() *cobra.Command {
2✔
18
        cmd := &cobra.Command{
2✔
19
                Use:   "server",
2✔
20
                Short: "Serve a frontend via gui",
2✔
21
                Run: func(cmd *cobra.Command, args []string) {
2✔
22
                        err := run(cmd)
×
23
                        if err != nil {
×
24
                                fmt.Println("Fatal: " + err.Error())
×
25
                                os.Exit(1)
×
26
                        }
×
27
                },
28
        }
29
        cmd.Flags().StringP(flagNameConfig, "c", "", "Config file to use")
2✔
30
        cmd.Flags().String(flagNameLogLevel, "", "Override the log level given in the config file")
2✔
31
        cmd.Flags().Bool(flagNameEnv, false, "Expand enviroment variables in the config file")
2✔
32

2✔
33
        return cmd
2✔
34
}
35

36
func run(cmd *cobra.Command) error {
×
37
        configPath, err := cmd.Flags().GetString(flagNameConfig)
×
38
        if err != nil {
×
39
                return err
×
40
        }
×
41
        logLevel, err := cmd.Flags().GetString(flagNameLogLevel)
×
42
        if err != nil {
×
43
                return err
×
44
        }
×
45
        env, err := cmd.Flags().GetBool(flagNameEnv)
×
46
        if err != nil {
×
47
                return err
×
48
        }
×
49

50
        cfg, err := config.LoadConfig(configPath, env, logLevel)
×
51
        if err != nil {
×
52
                return err
×
53
        }
×
54

UNCOV
55
        server, err := NewServer(cfg.Server, cfg.Storage)
×
56
        if err != nil {
×
57
                return err
×
58
        }
×
59

60
        return server.Run()
×
61
}
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