-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathadmin_app.go
More file actions
68 lines (51 loc) · 1.43 KB
/
admin_app.go
File metadata and controls
68 lines (51 loc) · 1.43 KB
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
// ThreatSpec package main
package main
import (
"fmt"
"github.com/jawher/mow.cli"
"github.com/olekukonko/tablewriter"
"github.com/pki-io/controller"
"os"
)
type AdminApp struct {
env *controller.Environment
}
func NewAdminApp() *AdminApp {
app := new(AdminApp)
app.env = controller.NewEnvironment()
controller.UseLogger(logger)
return app
}
func (app *AdminApp) Exit() {
logger.Flush()
cli.Exit(0)
}
func (app *AdminApp) Fatal(err error) {
congrats := `*************************************************
* CONGRATULATIONS *
*************************************************
You may have just found a bug in pki.io :)
Please try reproducing the problem using the trace log level by running:
pki.io -l trace COMMAND [args...]
Let us know of the issue by raising an issue on GitHub here:
https://github.com/pki-io/core/issues
Or by dropping an email to: dev@pki.io
If possible, please include this full log output, including the error
and anything else relevant like what command you ran.
Many thanks,
The pki.io team`
logger.Critical(err)
fmt.Println(congrats)
cli.Exit(1)
}
func (app *AdminApp) NewTable() *tablewriter.Table {
logger.Debug("creating table")
table := tablewriter.NewWriter(os.Stdout)
table.SetAlignment(tablewriter.ALIGN_LEFT)
return table
}
func (app *AdminApp) RenderTable(table *tablewriter.Table) {
logger.Debug("rendering output")
logger.Flush()
table.Render()
}