iof

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 29 Imported by: 0

README

iof

Literp Frontend Go Lib

Documentation

Index

Constants

View Source
const APPYAML = "app.yaml"
View Source
const ASTERISK = "*"
View Source
const BACKCOLON = "\b:"
View Source
const BACKCOMMA = "\b,"
View Source
const BACKDOT = "\b."
View Source
const CAPTIONYAML = "outcaption.yaml"
View Source
const COLON = ":"
View Source
const COMMA = ","
View Source
const COOKIE = "cookie"
View Source
const CR = '\n'
View Source
const DATAYAML = "data.yaml"
View Source
const DEFLIMIT = 50
View Source
const DEFOFFSET = 0
View Source
const DOT = "."
View Source
const ERROR = "error"
View Source
const EXIT = "exit"
View Source
const FOOTER = "footer"
View Source
const HEADER = "header"
View Source
const HEADYAML = "outhead.yaml"
View Source
const HYPHEN = "-"
View Source
const IDATTR = "id"
View Source
const INSTRUCTYAML = "instruct.yaml"
View Source
const LABELYAML = "label.yaml"
View Source
const LIMIT = "limit"
View Source
const MENUYAML = "menu.yaml"
View Source
const MESSAGE = "message"
View Source
const NAMEATTR = "name"
View Source
const OAUTH2 = "oauth2"
View Source
const OFFSET = "offset"
View Source
const OUTPUTYAML = "print.yaml"
View Source
const PAGE = "page"
View Source
const PLUS = "+"
View Source
const QUESTION = "?"
View Source
const QUIT = "quit"
View Source
const REFORMYAML = "reform.yaml"
View Source
const RESULT = "result"
View Source
const RETURNYAML = "return.yaml"
View Source
const SCRIPTYAML = "inscript.yaml"
View Source
const SESSIONUSER = "session_user"
View Source
const SESSIONZADM = "session_zadm"
View Source
const SESSIONZONE = "session_zone"
View Source
const SPACE = " "
View Source
const STRUCTYAML = "outstruct.yaml"
View Source
const TAB = "\t"
View Source
const TASKYAML = "task.yaml"
View Source
const TEXTYAML = "text.yaml"
View Source
const THREEDOT = "..."
View Source
const TID_InfoGen = "INFO_"
View Source
const TID_SelfUser = "me_"
View Source
const TID_SelfZone = "us_"
View Source
const TID_UpUser = "ui_"
View Source
const TID_UpZone = "zi_"
View Source
const TOKEN = "access_token"
View Source
const TOKENJSON = "token.json"
View Source
const TOKENTYPE = "token_type"
View Source
const T_bool = "bool"
View Source
const T_date = "date"
View Source
const T_float = "float"
View Source
const T_int = "int"
View Source
const T_ints = "int[]"
View Source
const T_pwd = "pwd"
View Source
const T_str = "str"
View Source
const T_strs = "str[]"
View Source
const T_time = "time"
View Source
const UNDERSCORE = "_"
View Source
const USERATTR = "user"
View Source
const ZADMATTR = "zadmin"
View Source
const ZONEATTR = "zone"

Variables

View Source
var ACCESSTOKEN string
View Source
var APIACCESS string
View Source
var Agented = Valid // alias
View Source
var CANCEL string
View Source
var DATA map[string][]map[string]string
View Source
var HIDTASKS []map[string]string
View Source
var INPUT_NATIVE_TYPES = []string{T_int, T_float, T_bool, T_date, T_time, T_pwd, T_str, T_strs, T_ints}
View Source
var LABELS map[string]string
View Source
var MAXSTRLEN int
View Source
var OUTPUTS map[string]map[string]string
View Source
var PROMPT string
View Source
var REFORMS map[string]map[string]string
View Source
var RETURNS map[string]map[string]string
View Source
var SERVERENDPOINT string
View Source
var StrFunctions map[string]StrFunc
View Source
var TEXTS map[string]string
View Source
var TOPTASKS []map[string]string

Functions

func AUTHORIZED

func AUTHORIZED() string

func Action

func Action(menuid string, args map[string]interface{})

process user menu option with or without args

func Agent

func Agent(gofunc string, args map[string]interface{})

call a function by name and parse map arguments

func Agentize

func Agentize(option string) string

parse menu option to agent func

func Any

func Any(src map[string]string) map[string]any

assertion map of (string) to (any)

func ApiCall

func ApiCall(endpoint string, sparam string) map[string]any

get raw data from server

func ApiOut

func ApiOut(endpoint string, sparam string)

output/print raw data from server

func App

func App() map[string]interface{}

load app config from app.yaml

func ArgPost added in v1.0.7

func ArgPost(args []string) map[string]interface{}

cli post with args

func ArgPost2 added in v1.0.7

func ArgPost2(args []string) [][]string

cli post with args, output csv

func Arrange added in v1.0.7

func Arrange(data map[string]interface{}) []string

arrange map keys/heads alphabetically

func Array

func Array(data []interface{}, structure []string) [][]string

get all rows from resultset["result"]

func Ask

func Ask(route string, sparam string)

global instance of Standalone.Ask

func BYBB

func BYBB(path string) map[string]map[string]map[string]string

load yaml with map[string]map[string]map[string]string

func Bool

func Bool(data any) (any, error)

use with Input() convert data to bool

func CSV

func CSV(data string) [][]string

load data from csv text/string

func Call

func Call(endpoint string, moduleid string, functionid string, jsondata string) map[string]interface{}

call for data function and get response from server

func Callup

func Callup(level int) string

get calling function name set level=0 for owner func

func Capitalize

func Capitalize(str string) string

capitalize first letter of string

func Caption

func Caption() map[string]map[string]string

load caption.yaml into string map

func Captioner

func Captioner(id string) map[string]string

get captions for module <id>

func Captioning

func Captioning(id string, attr string, defval string) string

get exact caption in module <id> using default value

func Cash

func Cash(num any) string

format float number string with thousands separator [,]

func Cdate

func Cdate(data any) (any, error)

use with Input() convert data to Date()

func CheckExist

func CheckExist(checkapi string, colid string) func(any) (any, error)

func CheckNone

func CheckNone(args ...any) func(any) (any, error)

just check nothing

func CheckNotExist

func CheckNotExist(checkapi string, colid string) func(any) (any, error)

func CheckNothing

func CheckNothing(checkapi string, colid string) func(any) (any, error)

func Cls

func Cls()

clear screen

func Col

func Col(data map[string]any, structure []string, heads []string)

output structured column from data row

func Column

func Column(id string, data map[string]any, structing []string, heading []string, defheader string)

output raw json data as a column with specific structure and headers

func Confirm

func Confirm() bool
func Cookie()

func Csv

func Csv(path string) [][]string

load data from large csv file

func CsvArray added in v1.0.7

func CsvArray(data []interface{}, structure []string) [][]string

get all rows from resultset["result"] as csv with heads

func CsvOut added in v1.0.7

func CsvOut(data [][]string)

output raw csv data

func Ctime

func Ctime(data any) (any, error)

use with Input() convert data to Time()

func Dat

func Dat(data map[string]string, structure []string)

output preserved data list

func Data

func Data() map[string][]map[string]string

load data.yaml for prebuilt data list

func DataList

func DataList(id string) (map[string]string, []string, []string)

load yaml data instead of server call

func DataReform

func DataReform(apifunc string, resultset []map[string]any)

reformat time and number strings as required

func DataTitle

func DataTitle(text string)

func Date

func Date(data string) (string, error)

Convert uk date to rfc3339

func DbBool

func DbBool(data bool) int

apply bool to db bool

func Default

func Default(data map[string]interface{}, key string, value any)

set default value of a ref-object item

func Deluser

func Deluser()

func Delzadm

func Delzadm()

func Delzone

func Delzone()

func Direct

func Direct()

api call

func DirectCall

func DirectCall(functionid string, jsondata string) map[string]interface{}

use shortened Call() to call for server data as an agent function

func Do

func Do(command string, param string)

run cli command with one argument command "hello", "init", "net" etc

func ERRORDELETE

func ERRORDELETE() string

func ERRORINPUT

func ERRORINPUT() string

func ERRORSAVE

func ERRORSAVE() string

func Echo

func Echo(id string, data map[string]any, defheader string)

output raw json data as a column using given structure

func Empty

func Empty(result map[string]interface{}) bool

this bool indicates that server database resulset contains nothing

func Endpoint

func Endpoint(route string) string

get endpoint url from route id

func Err

func Err(result map[string]interface{}) string

get server calling error message

func Error

func Error(text string)

func Escape

func Escape(data string) string

clear all puncs in string

func Exist

func Exist(checkapi string, colid string, trueifexist bool) func(any) (any, error)

check if resultset is not empty from api call

func Extract

func Extract(data string) []string

extract string to array

func Failed

func Failed(result map[string]interface{}) bool

this bool indicates that server calling failed

func False

func False(data any) bool

check var as boolean

func FilePost added in v1.0.7

func FilePost(args []string) map[string]interface{}

cli post from arg file

func FilePost2 added in v1.0.7

func FilePost2(args []string) [][]string

cli post from arg file, output csv

func Find

func Find(data []map[string]string, key, term string) map[string]string

retrieve single first map of Search() function

func First

func First(data []interface{}, structure []string) []string

get first row (dict) from resultset

func Float

func Float(data any) (any, error)

use with Input() convert data to float

func Float64

func Float64(data string) float64

convert string to float

func Form

func Form(data string, format string) string

reformat input string for names and ids

func FromAny

func FromAny(src map[string]any) map[string]string

assertion map of (any) to (string)

func Fstr

func Fstr(rawstr string, agrs ...any) string

clone python f-string with [%v] values

func Get

func Get(data map[string]string, attr string) string

get [map] object attr as string

func GetBool

func GetBool(prompt string, defval bool) bool

user enters a boolean value

func GetDate

func GetDate(require bool, prompt string, defval string) string

user enters a date

func GetFloat

func GetFloat(require bool, prompt string, hprompt string, defval float64, errvalue string) float64

user enters a float with api check

func GetInput

func GetInput(apifunc string) map[string]interface{}

make data input for calling api service need further process for int[] before posting

func GetInt

func GetInt(require bool, prompt string, hprompt string, defval int, errvalue string, checkfunc func(any) (any, error)) int

user enters an integer with api check

func GetLogin

func GetLogin(endpoint string)

user enters credentials

func GetOne

func GetOne(require bool, prompt string, values []string, defval string) string

user enters a simple choice from options

func GetPwd

func GetPwd(prompt string) string

user enters a password

func GetStr

func GetStr(require bool, prompt string) string

user enters a simple string

func GetString

func GetString(require bool, prompt string, hprompt string, defval string, errvalue string, checkfunc func(any) (any, error)) string

user enters a string with api check

func GetTime

func GetTime(require bool, prompt string, defval string) string

user enters a time [hour:min]

func Getuser

func Getuser() string

func Getzadm

func Getzadm() string

func Getzone

func Getzone() string

func Go

func Go(menu string)

open menu from cli argument

func Head() map[string]map[string]string

load head.yaml into string map

func Header(heading map[string]string, structure []string) []string

get user-friendly headers for data output

func Heading

func Heading(id string) []string

get headers from head.yaml for output

func Heads

func Heads(id string) map[string]string

get struct heads from head.yaml

func HidTask

func HidTask() []map[string]string

get all hidden tasks

func INVALIDDATA

func INVALIDDATA() string

func INVALIDINPUT

func INVALIDINPUT() string

func INVALIDSTRUCT

func INVALIDSTRUCT() string

func In

func In(val int, data []int) bool

check integer in slice

func Include

func Include(val any, data []any) bool

check any value in slice

func InfoGen added in v1.0.5

func InfoGen(apifunc string) bool

check api func if is info generator

func InfoTitle added in v1.0.5

func InfoTitle(text string)

func Input

func Input(require bool, check func(any) (any, error), prompt string, hprompt string, defval any, errinput string, errvalue string) any

input from stdin with value checking

func Inscript

func Inscript() map[string]map[string]map[string]string

load inscript.yaml into map

func Instruct

func Instruct() map[string][]string

load instruct.yaml into string slices

func Int

func Int(data any) (any, error)

use with Input() convert data to integer

func Integer

func Integer(data string) int

convert string to integer

func Integers

func Integers(data string) []int

extract string to array of int

func Interval

func Interval(data string) []int

extract string to int interval

func Ints

func Ints(data string) ([]int, bool)

extract str to int range

func IsArray

func IsArray(data any) bool

func IsBool

func IsBool(data any) bool

func IsFloat

func IsFloat(data any) bool

func IsInt

func IsInt(data any) bool

func IsMap

func IsMap(data any) bool

func IsStr

func IsStr(value any) bool

func JSON added in v1.0.6

func JSON(data []byte) map[string]interface{}

load data from json bytes slice

func Jname

func Jname(name string) string

generate "name" jsondata

func Json

func Json(path string) map[string]interface{}

load data from json file

func JsonPost added in v1.0.6

func JsonPost(path string) map[string]interface{}

api post with json file data

func JsonsPost added in v1.0.6

func JsonsPost(paths []string) map[string]map[string]interface{}

api post with multiple json files

func LOGINERROR

func LOGINERROR() string

func Label

func Label() map[string]string

load label.yaml for labels

func Len added in v1.0.3

func Len(data string) int

get length of utf8 str

func List

func List(id string, defheader string)

output given data list

func LoadToken

func LoadToken() (string, error)

func Login

func Login(endpoint string, username string, password string) error

login to server and start working session

func Lower

func Lower(str string) string

func MD5

func MD5(text string) string

get md5 hash of string

func MSG_back

func MSG_back() string

func MSG_choice

func MSG_choice() string

func MSG_exit

func MSG_exit() string

func MSG_login_name

func MSG_login_name() string

func MSG_login_password

func MSG_login_password() string

func MSG_password_not_matched

func MSG_password_not_matched() string

func Map

func Map(data []interface{}) []map[string]any

convert server response interface to map

func Matched

func Matched(var1 any, var2 any) bool

check two vars equal

func Menu() map[string][]string

load menu.yaml for menu options

func MenuLine(text string)
func MenuTitle(text string)

func MultiOptioned

func MultiOptioned(choices []string, total int) []int

get valid menu multi-options index+1

func NODATAFOUND

func NODATAFOUND() string

func Named added in v1.0.5

func Named(name string, prefix string) bool

check if string starts with certain prefix

func Nice

func Nice(data any) string

make nil as blank str

func Nil

func Nil(data any) bool

func None

func None(data any) (any, error)

use with Input() for none

func Now

func Now() string

get current standard rfc3339 timestamp

func Offset

func Offset(inputs map[string]interface{}, deflimit int, defoffset int, page string, limit string, offset string)

recalculate database result offset for server calling

func Option

func Option(menuid string, multi bool) any

run a menu then get users selection

func Optioned

func Optioned(choice string, total int) int

get valid menu option index+1

func Optionize

func Optionize(option string) string

parse menu option to function id

func Out

func Out(data map[string]any)

output raw json data

func Output

func Output() map[string]map[string]string

load print.yaml for labels

func Paginate

func Paginate(inputs map[string]interface{})

recalculate offset value for database resulset paginating

func Paint

func Paint(target string, text string)

print colored text via agent

func Parse

func Parse(sdata string) map[string]interface{}

implement javascript json.parse

func Password

func Password(prompt string, errinput string) string

input password from stdin with mask

func Pick

func Pick(data []string, id string, structure []string) string

get an item from structured slice

func Post

func Post()

api post

func Print

func Print(id string, endpoint string, sparam string)

output raw data (got from server) as a column

func Prompt

func Prompt() string

func Pull

func Pull(data map[string]any, attr string) any

get [map] object attr as any type

func Ranged

func Ranged(val int, data []int) bool

check integer in range

func RawCsvArray added in v1.0.7

func RawCsvArray(data []interface{}) [][]string

get resultset["result"] as head-sorted csv

func Reform

func Reform() map[string]map[string]string

load reform.yaml for output models

func Response

func Response(resp *http.Response) (map[string]interface{}, error)

process server response

func Result

func Result(data map[string]interface{}) []interface{}

get raw data (list of dicts) from resultset

func Return

func Return() map[string]map[string]string

load return.yaml for output models

func Row

func Row(index int, data []interface{}, structure []string) []string

get a row (dict) from resultset["result"]

func SaveCsv added in v1.0.7

func SaveCsv(data [][]string, path string) (string, error)

save csv from CsvArray() or RawCsvArray()

func SaveToken

func SaveToken(token string) error

func Scan

func Scan(prompt string, hprompt string, errinput string) string

raw input from stdin

func Search(data []map[string]string, key, term string) []map[string]string

retrieve maps in data slice where specific key matches given term

func Select

func Select(multi bool, title string, options []string, labels map[string]string) any

create menu from map of functions id and name

func SelfUser

func SelfUser(apifunc string) bool

check api func for own user

func SelfZone

func SelfZone(apifunc string) bool

check api func for own client/zone

func Server

func Server(endpoint string, sparam string) (map[string]interface{}, error)

call server with json-string parameter using both methods

func ServerDo

func ServerDo(endpoint string, sparam string, access_token string) (map[string]interface{}, error)

call server with json-string parameter using stored token

func ServerGet

func ServerGet(endpoint string, sparam string) (map[string]interface{}, error)

call server with json-string parameter using cookie

func Setuser

func Setuser(name string)

set/delete/get user name of working session

func Setzadm

func Setzadm(status string)

set/delete/get user admin privilege of working session

func Setzone

func Setzone(id string)

set/delete/get client id of working session

func Sfalse added in v1.0.7

func Sfalse(data string) bool

func Snil

func Snil(data string) bool

func Split

func Split(data string, separator string) []string

split string to array

func StdJson added in v1.0.6

func StdJson(name string, arg ...string) map[string]interface{}

load data from json output

func Str

func Str(data any) (any, error)

use with Input() convert data to string

func StrBool

func StrBool(data string) string

Convert str bool to yes/no

func StrCash

func StrCash(num string) string

func StrCut added in v1.0.5

func StrCut(text string) string

shorten long string

func StrDate

func StrDate(time string) string

convert db time to date

func StrZip

func StrZip(text string) string

shorten sensitive string

func String

func String(data any) string

convert data to string

func Stringify

func Stringify(data map[string]interface{}) string

implement javascript json.stringify

func Strs

func Strs(data string) ([]string, bool)

extract str to str range

func Struct

func Struct() map[string][]string

load struct.yaml into string slices

func Structify

func Structify(data map[string]any, structure []string) []string

make data row object structured slice for output

func Structing

func Structing(id string) []string

get structs from struct.yaml

func Strue added in v1.0.7

func Strue(data string) bool

func Tab

func Tab(data []string) string

format table row from slice

func TabEcho

func TabEcho(id string, data []map[string]any, defheader string)

output raw json data as a table using given structure

func Table

func Table(head []string, data [][]string, pad int)

output table from data set

func Tablet

func Tablet(data []map[string]any, cols []string, heads map[string]string)

output table from database resultset

func Task

func Task() map[string][]map[string]string

load task.yaml for app tasks

func Text

func Text() map[string]string

load text.yaml for texts

func Time

func Time(data string) (string, error)

Adjust hour:minute as rfc3339

func ToUpdate

func ToUpdate(apifunc string) bool

this bool indicates that database is to be updated after api calling

func TopTask

func TopTask() []map[string]string

get all app top-lavel tasks

func True

func True(data any) bool

check var as boolean

func Truncate added in v1.0.5

func Truncate(data string, maxlen int) string

truncate long text or string

func Type

func Type(data any) string

func Uid

func Uid(name string) int

get user id by name

func UpUser

func UpUser(apifunc string) bool

check api func if updates user-id

func UpZone

func UpZone(apifunc string) bool

check api func if updates zone-id

func Update

func Update(data map[string]interface{}, key string, value any)

update ref-object

func Upper

func Upper(str string) string

func Url

func Url(endpoint string, sparam string) string

parse url string for get request

func User

func User(input map[string]interface{})

update input["user"] from ["name"]

func Valid

func Valid(funcname string) bool

validate agent function

func Warning

func Warning(text string)

func Wide

func Wide(data [][]string) int

count columns of 2d matrix

func Widths

func Widths(data [][]string) []int

get columns width of text matrix

func Writer

func Writer(pad int) *tabwriter.Writer

standard tabwriter.NewWriter

func YAML

func YAML(data []byte) map[string]interface{}

load data from yaml bytes slice

func YB

func YB(path string) map[string]string

load yaml with map[string]string

func YBB

func YBB(path string) map[string]map[string]string

load yaml with map[string]map[string]string

func YBBS

func YBBS(path string) map[string][]map[string]string

load yaml with map[string][]map[string]string

func YBS

func YBS(path string) map[string][]string

load yaml with map[string][]string

func Yaml

func Yaml(path string) map[string]interface{}

load structured data from yaml file

func Yamlb

func Yamlb(path string) []byte

load raw bytes from yaml file

func Yes

func Yes(data string) bool

convert string to bool to trigger some action

func Zid

func Zid(name string) int

get client id by name

func Zone

func Zone(input map[string]interface{})

caution to ambiguous ["name"]

func Zoner

func Zoner(route string)

init client/zone route: init/zone route: init/accounting parameter: zoneid [int]

Types

type Standalone

type Standalone struct{} // container of functions

func (Standalone) An_direct_api_call

func (c Standalone) An_direct_api_call()

launch direct api call [An_] stands for anonymous

func (Standalone) An_direct_api_post

func (c Standalone) An_direct_api_post()

post file data to server [An_] stands for anonymous

func (Standalone) An_init_accounting

func (c Standalone) An_init_accounting()

initialize client database [An_] stands for anonymous

func (Standalone) An_init_zone

func (c Standalone) An_init_zone()

initialize client zone [An_] stands for anonymous

func (Standalone) Ask

func (c Standalone) Ask(args map[string]interface{})

send request to server to get raw data

func (Standalone) Black

func (c Standalone) Black(args map[string]interface{})

func (Standalone) Blue

func (c Standalone) Blue(args map[string]interface{})

func (Standalone) Cyan

func (c Standalone) Cyan(args map[string]interface{})

func (Standalone) Green

func (c Standalone) Green(args map[string]interface{})

func (Standalone) Im

func (c Standalone) Im()

show saved user info

func (Standalone) Login

func (c Standalone) Login()

func (Standalone) Logout

func (c Standalone) Logout()

func (Standalone) Magenta

func (c Standalone) Magenta(args map[string]interface{})

func (Standalone) Me

func (c Standalone) Me()

show user login info

func (Standalone) Red

func (c Standalone) Red(args map[string]interface{})

func (Standalone) White

func (c Standalone) White(args map[string]interface{})

func (Standalone) Yellow

func (c Standalone) Yellow(args map[string]interface{})

type StrFunc

type StrFunc func(name string) string // for data reform

Jump to

Keyboard shortcuts

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