Skip to content

Commit

Permalink
misc: small fix or general refactoring i did not bother commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Oct 10, 2018
1 parent d070445 commit 058a686
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions session/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func NewEvent(tag string, data interface{}) Event {

func (e Event) Label() string {
m := e.Data.(LogMessage)
label := log.LevelNames[m.Level]
color := log.LevelColors[m.Level]
label := log.LevelName(m.Level)
color := log.LevelColor(m.Level)
return color + label + tui.RESET
}

Expand Down
37 changes: 19 additions & 18 deletions session/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,7 @@ const (
)

var (
// these are here because if colors are disabled,
// we need the updated tui.* variables
effects = map[string]string{
"{bold}": tui.BOLD,
"{dim}": tui.DIM,
"{r}": tui.RED,
"{g}": tui.GREEN,
"{b}": tui.BLUE,
"{y}": tui.YELLOW,
"{fb}": tui.FOREBLACK,
"{fw}": tui.FOREWHITE,
"{bdg}": tui.BACKDARKGRAY,
"{br}": tui.BACKRED,
"{bg}": tui.BACKGREEN,
"{by}": tui.BACKYELLOW,
"{blb}": tui.BACKLIGHTBLUE, // Ziggy this is for you <3
"{reset}": tui.RESET,
}
effects = map[string]string{}
PromptCallbacks = map[string]func(s *Session) string{
"{cidr}": func(s *Session) string {
return s.Interface.CIDR()
Expand Down Expand Up @@ -62,6 +45,24 @@ type Prompt struct {
}

func NewPrompt() Prompt {
// these are here because if colors are disabled,
// we need the updated tui.* variables
effects = map[string]string{
"{bold}": tui.BOLD,
"{dim}": tui.DIM,
"{r}": tui.RED,
"{g}": tui.GREEN,
"{b}": tui.BLUE,
"{y}": tui.YELLOW,
"{fb}": tui.FOREBLACK,
"{fw}": tui.FOREWHITE,
"{bdg}": tui.BACKDARKGRAY,
"{br}": tui.BACKRED,
"{bg}": tui.BACKGREEN,
"{by}": tui.BACKYELLOW,
"{blb}": tui.BACKLIGHTBLUE, // Ziggy this is for you <3
"{reset}": tui.RESET,
}
return Prompt{}
}

Expand Down
28 changes: 14 additions & 14 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,29 @@ type Session struct {
}

func New() (*Session, error) {
var err error
opts, err := core.ParseOptions()
if err != nil {
return nil, err
}

if *opts.NoColors || !tui.Effects() {
tui.Disable()
log.NoEffects = true
}

s := &Session{
Prompt: NewPrompt(),
Env: nil,
Active: false,
Queue: nil,
Prompt: NewPrompt(),
Options: opts,
Env: nil,
Active: false,
Queue: nil,

CoreHandlers: make([]CommandHandler, 0),
Modules: make([]Module, 0),
Events: nil,
UnkCmdCallback: nil,
}

if s.Options, err = core.ParseOptions(); err != nil {
return nil, err
}

if *s.Options.NoColors || !tui.Effects() {
tui.Disable()
log.NoEffects = true
}

if *s.Options.CpuProfile != "" {
if f, err := os.Create(*s.Options.CpuProfile); err != nil {
return nil, err
Expand Down
13 changes: 13 additions & 0 deletions vendor/github.com/evilsocket/islazy/log/level.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 058a686

Please sign in to comment.