/
bommtbf_cmd.go
86 lines (76 loc) · 2.55 KB
/
bommtbf_cmd.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"fmt"
"path/filepath"
"github.com/saycv/ebomgen"
"github.com/saycv/ebomgen/pkg/configuration"
logsupport "github.com/saycv/ebomgen/pkg/log"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
// NewBommtbfCmd returns the bommtbf command
func NewBommtbfCmd() *cobra.Command {
var verbose bool
var input string
var output string
var clsquality string
var clsenv string
var opsenv string
var degrade string
var logLevel string
rootCmd := &cobra.Command{
Use: "bommtbf -i infile -o outfile",
Short: `Fetch the bommtbf info`,
Args: cobra.ArbitraryArgs,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
lvl, err := log.ParseLevel(logLevel)
if err != nil {
fmt.Fprintf(cmd.OutOrStderr(), "unable to parse log level '%v'", logLevel)
return err
}
logsupport.Setup()
log.SetLevel(lvl)
log.SetOutput(cmd.OutOrStdout())
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
//if len(args) == 0 {
// return helpCommand.RunE(cmd, args)
//}
//attrs := parseAttributes(attributes)
//for _, sourcePath := range args {
//}
out, close := getOut(cmd, input, filepath.Dir(output))
if out != nil {
defer close()
path, _ := filepath.Abs(input)
path = filepath.ToSlash(path)
config := configuration.NewConfiguration(
configuration.WithInputFile(input),
configuration.WithOutputFile(output),
configuration.WithFrClsQuality(clsquality),
configuration.WithFrClsEnv(clsenv),
configuration.WithFrOpsEnv(opsenv),
configuration.WithFrDegrade(degrade),
configuration.WithCommand("bommtbf"))
err := ebomgen.CalcMtbfBasedPCP(config)
if err != nil {
return err
}
log.Infof("finished!!!")
}
return nil
},
}
rootCmd.SilenceUsage = true
flags := rootCmd.Flags()
flags.BoolVarP(&verbose, "verbose", "v", true, "verbose")
flags.StringVarP(&input, "input", "i", "test/pads/BOM/ex1_BOM.csv", "The path to the input schematic or netlist file")
flags.StringVarP(&output, "output", "o", "test/pads/BOM/ex1_BOM.bommtbf.csv", "The path for the output file")
flags.StringVarP(&clsquality, "clsquality", "q", "C1", "The component quality class")
flags.StringVarP(&clsenv, "clsenv", "c", "GB", "The component ambient temprature")
flags.StringVarP(&opsenv, "opsenv", "e", "GM1", "The component work temprature")
flags.StringVarP(°rade, "degrade", "d", "0.5", "The component stress value")
flags.StringVarP(&logLevel, "log", "l", "debug", "log level to set [debug|info|warning|error|fatal|panic]")
return rootCmd
}