Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[proposal] General table options/scheme to avoid code repeat #2

@ecoshub

Description

@ecoshub
table, _ := stable.ToTable(board)
table.GetFieldByName("GroupID").SetOptions(&stable.Options{CharLimit: 8})
table.GetFieldByName("Group").SetOptions(&stable.Options{CharLimit: 8})
table.GetFieldByName("OldGroupID").SetOptions(&stable.Options{Hide: true})
table.SetGeneralPadding(0)
table.SetCaption("Season Users")
fmt.Println(table)

// any change in the "board"

table, _ := stable.ToTable(board)
table.GetFieldByName("GroupID").SetOptions(&stable.Options{CharLimit: 8})
table.GetFieldByName("Group").SetOptions(&stable.Options{CharLimit: 8})
table.GetFieldByName("OldGroupID").SetOptions(&stable.Options{Hide: true})
table.SetGeneralPadding(0)
table.SetCaption("Season Users")
fmt.Println(table)


// ---------------------------------------------------
// proposal:

scheme := stable.Scheme{
    FieldOptionsWithName: {
	"GroupID": &stable.Options{CharLimit: 8},
	"Group": &stable.Options{CharLimit: 8},
	"OldGroupID": &stable.Options{Hide: true},
    },
    DefaultGeneralPadding: 0,
    Caption: "Season Users",
}

table, _ := stable.ToTableWithScheme(leaderboard, scheme)

// any change in the "board"

table, _ := stable.ToTableWithScheme(leaderboard, scheme)

Need to set all options for all fields over and over again to print the table with same form.

There must be a scheme or options object to merge all settings in to one variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions