hub

package
v0.0.0-...-5e95302 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 28 Imported by: 0

README

Besides the test files, the important stuff here is:

  • hub.go
  • hub.pf
  • hab snap

hub.pf is the Pipefish service that the user talks to when they talk to the hub. hub.go actually inmplements it.

Much of the logic has to be in hub.go, with hub.pf a thin skin over the top, because there are lots of things that can only be done from Go and not from Pipefish, e.g. compiling and running Pipefish services. A few things would be better off in hub.pf but are in hub.go for historical reasons.

The way it works is that the hub.pf file has a type Hub wrapping io.Writer, and a variable initialized as HUB Hub? = NULL. On creation of the hub service, we inject an io.Writer into the variable, where the Write method tells the hub.pf to do the thing in question.

(The reason we do it this way rather than injecting the Go *hub.Hub object itself is that this requires the production of an .so file which takes over a minute to compile and is larger than the main executable.)

hub snap contains logic for writing tests in the REPL.

Documentation

Index

Constants

View Source
const (
	BAD    = "bad"
	GOOD   = "good"
	RECORD = "record"
)
View Source
const HELP = "\nUsage: pipefish [-v | --version] [-h | --help]\n" +
	"                <command> [args]\n\n" +
	"Commands are:\n\n" +
	"  tui           Starts the Pipfish TUI (text user interface).\n" +
	"  run <file>    Runs a Pipefish script if it has a `main` command.\n\n"

Variables

View Source
var (
	MARGIN         = 92
	GREEN_OK       = ("\033[32mOK\033[0m")
	WAS            = Green("was") + ": "
	GOT            = Red("got") + ": "
	TEST_PASSED    = Green("Test passed!") + "\n"
	VERSION        = "0.6.8"
	BULLET         = "  ▪ "
	BULLET_SPACING = "    " // I.e. whitespace the same width as BULLET.
	GOOD_BULLET    = Green("  ▪ ")
	BROKEN         = Red("  ✖ ")
	PROMPT         = "→ "
	INDENT_PROMPT  = "  "
	ERROR          = text.ERROR
	RT_ERROR       = text.ERROR
	HUB_ERROR      = "<R>Hub error</>: "
)

Functions

func Cyan

func Cyan(s string) string

func FlattenedFilename

func FlattenedFilename(s string) string

func Green

func Green(s string) string
func Logo() string

func MakeSnapIo

func MakeSnapIo(sv *pf.Service, out io.Writer, sn *Snap) (*snapInHandler, *snapOutHandler)

func MakeTestIoHandler

func MakeTestIoHandler(sv *pf.Service, out io.Writer, scanner *bufio.Scanner, testOutputType TestOutputType) (*TestInHandler, *TestOutHandler)

func Red

func Red(s string) string

func ServiceDo

func ServiceDo(serviceToUse *pf.Service, line string) pf.Value

func StartServiceFromCli

func StartServiceFromCli()

Types

type Hub

type Hub struct {
	Services map[string]*pf.Service // The services the hub knows about.

	Out io.Writer

	Sources map[string][]string

	Db *sql.DB

	// The username and password of the person logged into the terminal.
	TerminalUsername string
	TerminalPassword string
	// contains filtered or unexported fields
}

func New

func New(path string, out io.Writer) *Hub

func (*Hub) CurrentServiceIsBroken

func (hub *Hub) CurrentServiceIsBroken() bool

func (*Hub) Do

func (hub *Hub) Do(line, username, password, passedServiceName string, external bool) (string, bool)

This takes the input from the REPL, interprets it as a hub command if it begins with 'hub'; as an instruction to the os if it begins with 'os', and as an expression to be passed to the current service if none of the above hold.

func (*Hub) DoHubCommand

func (hub *Hub) DoHubCommand(line string)

func (*Hub) GetAndReportErrors

func (hub *Hub) GetAndReportErrors(sv *pf.Service)

func (*Hub) GetPretty

func (hub *Hub) GetPretty(s string) string

func (*Hub) MakeFilepath

func (h *Hub) MakeFilepath(scriptFilepath string) string

func (*Hub) OpenHubFile

func (h *Hub) OpenHubFile(hubFilepath string)

func (*Hub) Quit

func (hub *Hub) Quit()

func (*Hub) Repl

func (hub *Hub) Repl()

TODO --- once the highlighting is semantic and not syntactic, we'll need a different highlighter for each service.

func (*Hub) RunTest

func (hub *Hub) RunTest(scriptFilepath, testFilepath string, testOutputType TestOutputType)

func (*Hub) SaveAndPropagateHubStore

func (hub *Hub) SaveAndPropagateHubStore()

func (*Hub) StartAndMakeCurrent

func (hub *Hub) StartAndMakeCurrent(username, serviceName, scriptFilepath string) bool

func (*Hub) StartHttp

func (h *Hub) StartHttp(args []string, isHttps bool)

func (*Hub) TestScript

func (hub *Hub) TestScript(scriptFilepath string, testOutputType TestOutputType)

func (*Hub) WriteError

func (hub *Hub) WriteError(s string)

func (*Hub) WritePretty

func (hub *Hub) WritePretty(s string)

func (*Hub) WriteString

func (hub *Hub) WriteString(s string)

type Snap

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

func NewSnap

func NewSnap(scriptFilepath, testFilename string) *Snap

func (*Snap) AddInput

func (sn *Snap) AddInput(s string)

func (*Snap) AddOutput

func (sn *Snap) AddOutput(s string)

func (*Snap) AppendOutput

func (sn *Snap) AppendOutput(s string)

func (*Snap) Save

func (sn *Snap) Save(st string) string

type TestInHandler

type TestInHandler struct {
	Fail bool
	// contains filtered or unexported fields
}

func (*TestInHandler) Get

func (iH *TestInHandler) Get() string

type TestOutHandler

type TestOutHandler struct {
	Fail bool
	// contains filtered or unexported fields
}

func (*TestOutHandler) Out

func (oH *TestOutHandler) Out(v pf.Value)

func (*TestOutHandler) Write

func (oH *TestOutHandler) Write(s string)

type TestOutputType

type TestOutputType int
const (
	ERROR_CHECK TestOutputType = iota
	SHOW_ALL
	SHOW_DIFF
)

Jump to

Keyboard shortcuts

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