new: implemented events.stream.output (closes #169). new: implemented -no-colors argument.

This commit is contained in:
evilsocket 2018-03-13 13:20:21 +01:00
commit e40219976c
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
9 changed files with 97 additions and 56 deletions

View file

@ -15,23 +15,6 @@ const (
DefaultPrompt = "{by}{fw}{cidr} {fb}> {env.iface.ipv4} {reset} {bold}» {reset}"
)
var PromptEffects = map[string]string{
"{bold}": core.BOLD,
"{dim}": core.DIM,
"{r}": core.RED,
"{g}": core.GREEN,
"{b}": core.BLUE,
"{y}": core.YELLOW,
"{fb}": core.FG_BLACK,
"{fw}": core.FG_WHITE,
"{bdg}": core.BG_DGRAY,
"{br}": core.BG_RED,
"{bg}": core.BG_GREEN,
"{by}": core.BG_YELLOW,
"{blb}": core.BG_LBLUE, // Ziggy this is for you <3
"{reset}": core.RESET,
}
var PromptCallbacks = map[string]func(s *Session) string{
"{cidr}": func(s *Session) string {
return s.Interface.CIDR()
@ -71,7 +54,26 @@ func (p Prompt) Render(s *Session) string {
prompt = DefaultPrompt
}
for tok, effect := range PromptEffects {
// these are here because if colors are disabled,
// we need the updated core.* variables
var effects = map[string]string{
"{bold}": core.BOLD,
"{dim}": core.DIM,
"{r}": core.RED,
"{g}": core.GREEN,
"{b}": core.BLUE,
"{y}": core.YELLOW,
"{fb}": core.FG_BLACK,
"{fw}": core.FG_WHITE,
"{bdg}": core.BG_DGRAY,
"{br}": core.BG_RED,
"{bg}": core.BG_GREEN,
"{by}": core.BG_YELLOW,
"{blb}": core.BG_LBLUE, // Ziggy this is for you <3
"{reset}": core.RESET,
}
for tok, effect := range effects {
prompt = strings.Replace(prompt, tok, effect, -1)
}

View file

@ -138,6 +138,8 @@ func New() (*Session, error) {
return nil, err
}
core.InitSwag(*s.Options.NoColors)
if *s.Options.CpuProfile != "" {
if f, err := os.Create(*s.Options.CpuProfile); err != nil {
return nil, err