github.com/crowdsecurity/crowdsec@v1.6.1/cmd/crowdsec-cli/console_table.go (about)

     1  package main
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/aquasecurity/table"
     7  
     8  	"github.com/crowdsecurity/crowdsec/pkg/csconfig"
     9  	"github.com/crowdsecurity/crowdsec/pkg/emoji"
    10  )
    11  
    12  func cmdConsoleStatusTable(out io.Writer, consoleCfg csconfig.ConsoleConfig) {
    13  	t := newTable(out)
    14  	t.SetRowLines(false)
    15  
    16  	t.SetHeaders("Option Name", "Activated", "Description")
    17  	t.SetHeaderAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft)
    18  
    19  	for _, option := range csconfig.CONSOLE_CONFIGS {
    20  		activated := emoji.CrossMark
    21  
    22  		switch option {
    23  		case csconfig.SEND_CUSTOM_SCENARIOS:
    24  			if *consoleCfg.ShareCustomScenarios {
    25  				activated = emoji.CheckMarkButton
    26  			}
    27  		case csconfig.SEND_MANUAL_SCENARIOS:
    28  			if *consoleCfg.ShareManualDecisions {
    29  				activated = emoji.CheckMarkButton
    30  			}
    31  		case csconfig.SEND_TAINTED_SCENARIOS:
    32  			if *consoleCfg.ShareTaintedScenarios {
    33  				activated = emoji.CheckMarkButton
    34  			}
    35  		case csconfig.SEND_CONTEXT:
    36  			if *consoleCfg.ShareContext {
    37  				activated = emoji.CheckMarkButton
    38  			}
    39  		case csconfig.CONSOLE_MANAGEMENT:
    40  			if *consoleCfg.ConsoleManagement {
    41  				activated = emoji.CheckMarkButton
    42  			}
    43  		}
    44  
    45  		t.AddRow(option, activated, csconfig.CONSOLE_CONFIGS_HELP[option])
    46  	}
    47  
    48  	t.Render()
    49  }