SerenadeMi

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

README

SerenadeMi

A dynamic menu system for writing BBsMi appllications and more

Table of Contents

Installation

go get github.com/BBsMi/SerenadeMi

Usage

Steps to use

Make sure your go.mod is correctly initalized for your project
go mod init (package url)
Create subfolder "menu" in your current project
mkdir menu
Import menu
import "(your package url)/menu"
 

Golang will not accept new functions added to an external package. To get around this we must declare we are extending the packages struct. In menu/types.go:

package SerenadeMiFunctions

import "github.com/BBsMi/SerenadeMi"

type Inits SerenadeMi.Inits

func Init() Inits {
  return Inits{}
}
Create your functions

Create your functions in ./menu using some sort of standardize naming scheme (examples: F(function number).go, (function short name).go, (function number).go) using the following template. Replace FXXX with F and that functions number.

package SerenadeMiFunctions

import "github.com/BBsMi/SerenadeMi"

func (i *Inits) FXXX_Init() SerenadeMi.Entry { return nil }

func FXXX(attrib *interface{}) error { return nil }

Using your new menu

Boilerplate ( go mod init myapp with this example )

package main

import (
  smf "myapp/menu"
  "github.com/BBsMi/SerenadeMi"
)

func main() {
  // Init our functions
  om := smf.Init()

  // Load menu into engine
  smi := SerenadeMi.Init(&om)

  smi.Spew()
  
  // smi.Exec(uint(1))
  // smi.Exec("hello")
  // smi.Pager(uint(0), uint(100))
}

Support

Please open an issue for support.

Contributing

Please contribute using Github Flow. Create a branch, add commits, and open a pull request.

License

(c) 2023 GNU AFFERO GENERAL PUBLIC LICENSE v3.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func Init

func Init(i any) *Engine

func Init(i any) *[]Entry {

func (*Engine) Exec

func (e *Engine) Exec(query any) error

query needs to be reduced to either a single word or number in it's:s correct type eventually we'll be able to add attributes here to passthrough

func (*Engine) Pager

func (e *Engine) Pager(from, to uint) *[]*Entry

give a subset of entries to display

func (*Engine) Spew

func (e *Engine) Spew()

Spew your secrets

type Entry

type Entry struct {
	FnNumb uint                            // Function Number
	FnName string                          // Function Name
	SDesc  string                          // Function Short Description
	Ldesc  string                          // Function Long Description
	Fn     func(attrib *interface{}) error // Function itself
}

type Inits

type Inits struct{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL