-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.go
45 lines (39 loc) · 870 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
// led reads the state of a LED or change it.
package main
import (
"errors"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"periph.io/x/host/v3"
"periph.io/x/host/v3/sysfs"
)
func mainImpl() error {
verbose := flag.Bool("v", false, "verbose mode")
flag.Parse()
if !*verbose {
log.SetOutput(ioutil.Discard)
}
log.SetFlags(log.Lmicroseconds)
if flag.NArg() != 0 {
return errors.New("unexpected argument, try -help")
}
if _, err := host.Init(); err != nil {
return err
}
for _, led := range sysfs.LEDs {
fmt.Printf("%s: %s\n", led, led.Func())
}
return nil
}
func main() {
if err := mainImpl(); err != nil {
fmt.Fprintf(os.Stderr, "led: %s.\n", err)
os.Exit(1)
}
}