refactor: add comments for exported functions

This commit is contained in:
rigormorrtiss 2021-08-18 22:15:22 +04:00
parent baba0b6259
commit 9bb8dce3d0
10 changed files with 12 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import (
"github.com/rivo/tview"
)
// NewApp creates and returns a new application.
func NewApp(onAppInputCapture func(*tcell.EventKey) *tcell.EventKey) (app *tview.Application) {
app = tview.NewApplication().
EnableMouse(true).

View file

@ -4,6 +4,7 @@ import (
"github.com/rivo/tview"
)
// NewMainFlex creates and returns a new main flex.
func NewMainFlex(l *tview.List, treeV *tview.TreeView, textV *tview.TextView, i *tview.InputField) (mf *tview.Flex) {
lf := tview.NewFlex().
SetDirection(tview.FlexRow).

View file

@ -16,6 +16,7 @@ func newBaseLoginForm() (f *tview.Form) {
return
}
// NewLoginForm creates and returns a new login form.
func NewLoginForm(onLoginFormLoginButtonSelected func()) (f *tview.Form) {
f = newBaseLoginForm()
f.
@ -26,6 +27,7 @@ func NewLoginForm(onLoginFormLoginButtonSelected func()) (f *tview.Form) {
return
}
// NewMfaLoginForm creates and returns a new MFA login form.
func NewMfaLoginForm(onMfaLoginFormLoginButtonSelected func()) (f *tview.Form) {
f = newBaseLoginForm().
AddPasswordField("Code", "", 0, 0, nil).

View file

@ -6,6 +6,7 @@ import (
"github.com/rivo/tview"
)
// NewMessageInputField creates and returns a new message inputfield.
func NewMessageInputField(onMessageInputFieldInputCapture func(*tcell.EventKey) *tcell.EventKey, t *util.Theme) (i *tview.InputField) {
i = tview.NewInputField()
i.

View file

@ -5,6 +5,7 @@ import (
"github.com/rivo/tview"
)
// NewGuildsList creates and returns a new guilds list.
func NewGuildsList(onGuildsListSelected func(int, string, string, rune), t *util.Theme) (l *tview.List) {
l = tview.NewList()
l.

View file

@ -4,6 +4,7 @@ import (
"github.com/rivo/tview"
)
// NewMessagesTextView creates and returns a new messages textview.
func NewMessagesTextView(app *tview.Application) (textV *tview.TextView) {
textV = tview.NewTextView()
textV.

View file

@ -4,6 +4,7 @@ import (
"github.com/rivo/tview"
)
// NewChannelsTreeView creates and returns a new channels treeview.
func NewChannelsTreeView(onChannelsTreeViewSelected func(*tview.TreeNode)) (treeV *tview.TreeView) {
treeV = tview.NewTreeView()
treeN := tview.NewTreeNode("")

View file

@ -16,6 +16,7 @@ type Config struct {
Theme *Theme `json:"theme,omitempty"`
}
// NewConfig reads the configuration file (if exists) and returns a new config.
func NewConfig() *Config {
userHomeDir, err := os.UserHomeDir()
if err != nil {

View file

@ -8,6 +8,7 @@ import (
"github.com/rivo/tview"
)
// WriteMessage parses and writes the parsed message to the provided textview.
func WriteMessage(v *tview.TextView, clientID discord.UserID, m discord.Message) {
var b strings.Builder
switch m.Type {

View file

@ -2,6 +2,7 @@ package util
import "github.com/zalando/go-keyring"
// GetPassword retrieves the password in keyring for provided user.
func GetPassword(u string) string {
p, err := keyring.Get("discordo", u)
if err != nil {
@ -11,6 +12,7 @@ func GetPassword(u string) string {
return p
}
// SetPassword sets the password in keyring for provided user.
func SetPassword(u string, p string) {
if err := keyring.Set("discordo", u, p); err != nil {
panic(err)