stacker

package
v0.0.0-...-649a294 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BASE64 = "application/base64"
View Source
var TEXT = "text/plain"

Functions

func ClearAll

func ClearAll(cxt Config) string

Clear all items off the stack

func Color

func Color(code int, text string) string

Add some color to the output

func CreateItem

func CreateItem(cxt Config, text string)

Create an Item in the Stack

func Decode

func Decode(encoded string) string

func DeleteItem

func DeleteItem(cxt Config) string

Delete the top Item in the Stack

func Encode

func Encode(plaintext string) string

func ExpandPath

func ExpandPath(path string) string

* resolve tilde to the full path for a user

func FileDelete

func FileDelete(file string)

func FileExists

func FileExists(fileName string) bool

* test if a file exists

func FileRead

func FileRead(file string) []byte

* load a string from a file

func FileSave

func FileSave(file string, json_text []byte)

* save the database to a file

func HashItems

func HashItems(ctx Config) string

func Host

func Host(config Config)

func ListItems

func ListItems(ctx Config) string

Return a formated list of stack items but don't display encoded values

func PeekItem

func PeekItem(ctx Config) string

Return the first item off the stack without doing a Pop

func PopItem

func PopItem(ctx Config) string

func ReadFromStandardIn

func ReadFromStandardIn() string

Read in all the input from standard in

func ReadItem

func ReadItem(cxt Config) string

Read an Item from the Stack

func RemoveOld

func RemoveOld(cxt Config, limit int)

Remove items older then the limit

func RotateUp

func RotateUp(cxt Config) string

Rotate the stack up, taking the last item and making it the first

func TimeFrezer

func TimeFrezer(then int64)

used in tests to set a specific time, not live mode

func Time_now_unix

func Time_now_unix() int64

return the unix time stamp or the frozen time

func UpdateItem

func UpdateItem(cxt Config, text string) string

Update the top Item on the Stack

Types

type Config

type Config struct {
	Name   string
	Path   string
	Encode bool

	Host string
	Port int
}

func (Config) UserHomeDir

func (self Config) UserHomeDir() string

type Item

type Item struct {
	Time    int64
	Data    string
	Content string `json:",omitempty"`
}

One node in the Structure, has a time stamp for judging how long item is been stored.

func MakeEncodedItem

func MakeEncodedItem(data, content_type string) Item

func MakeItem

func MakeItem(data string) Item

Create a new Item struct using the current time as the time stamp

func (Item) Actual

func (self Item) Actual() string

extend the Item by adding Actual() which decodes the Data based on Content

func (Item) FromNow

func (self Item) FromNow() int

Take the difference of the Item time stamp from now

type Stacker

type Stacker struct {
	Name  string
	Items []Item
}

Stacker is the entire data structure for the file system, it contains a list of Items

func FromBytes

func FromBytes(raw []byte) *Stacker

Create a stacker struct from a byte array (json)

func (*Stacker) Clear

func (data *Stacker) Clear()

Reset the stack back to an empty state

func (Stacker) Peek

func (data Stacker) Peek() Item

Return the top item from the stack without removing it

func (*Stacker) Pop

func (data *Stacker) Pop() Item

Remove an item from the stack and return it

func (*Stacker) PopQueue

func (data *Stacker) PopQueue() Item

Remove the top item from the stack

func (*Stacker) Push

func (data *Stacker) Push(item Item)

Put an item onto the stack

func (*Stacker) Replace

func (data *Stacker) Replace(item Item) Item

replace the current top of the stack and replace it

func (*Stacker) RotateUp

func (data *Stacker) RotateUp()

take the last item on the stack and make it the first

func (*Stacker) Swap

func (data *Stacker) Swap()

Swap the top two item on the stack

func (Stacker) ToJson

func (data Stacker) ToJson() []byte

Creates a storable Json record for Stacker

type WebEntry

type WebEntry struct {
	Name   string
	Method string
	Path   string
	Help   string
	Action func(w http.ResponseWriter, r *http.Request)
}

func HostSet

func HostSet(config Config) []WebEntry

Create a list of WebEntry objects which can then be dynamically added to the web server

Jump to

Keyboard shortcuts

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