hub

package
v0.0.0-...-420b1db Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 40 Imported by: 0

README

Besides the test files, the important stuff here is:

  • hub.go
  • hub.pf

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.)

Documentation

Index

Constants

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" +
	"  wiki <file>   Returns a description of the file's API in GitHub wiki format.\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"
	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 AddAdmin

func AddAdmin(db *sql.DB, username, firstName, lastName, email, password string) error

func AddUser

func AddUser(db *sql.DB, username, firstName, lastName, email, password string) error

func AddUserToGroup

func AddUserToGroup(db *sql.DB, username, groupName string, owner bool) error

func ChangePassword

func ChangePassword(db *sql.DB, username, newPassword string) error

func CopyFile

func CopyFile(srcFile, dstFile string) error

func CreateGroup

func CreateGroup(db *sql.DB, groupName string) error

func Cyan

func Cyan(s string) string

func DropTables

func DropTables(db *sql.DB)

func GetGroupsOfService

func GetGroupsOfService(db *sql.DB, serviceName string) (string, error)

func GetGroupsOfUser

func GetGroupsOfUser(db *sql.DB, username string, ownGroups bool) (string, error)

func GetServicesOfGroup

func GetServicesOfGroup(db *sql.DB, groupName string) (string, error)

func GetServicesOfUser

func GetServicesOfUser(db *sql.DB, username string, ownServices bool) (string, error)

func GetUsersOfGroup

func GetUsersOfGroup(db *sql.DB, groupName string) (string, error)

func GetUsersOfService

func GetUsersOfService(db *sql.DB, serviceName string) (string, error)

func GetWiki

func GetWiki()

func Green

func Green(s string) string

func IsUserAdmin

func IsUserAdmin(db *sql.DB, username string) (bool, error)

func IsUserGroupOwner

func IsUserGroupOwner(db *sql.DB, username, groupName string) error

func IsUserInGroup

func IsUserInGroup(db *sql.DB, username, groupName string) (bool, error)

func LetGroupUseService

func LetGroupUseService(db *sql.DB, groupName, serviceName string) error

func MakePassword

func MakePassword() string

func ReadChar

func ReadChar() rune

func Red

func Red(s string) string

func ServiceDo

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

func SetOwnership

func SetOwnership(db *sql.DB, username, groupName string, owner bool) error

func StartServiceFromCli

func StartServiceFromCli()

func UnAddUserToGroup

func UnAddUserToGroup(db *sql.DB, username, groupName string) error

func UnLetGroupUseService

func UnLetGroupUseService(db *sql.DB, groupName, serviceName string) error

func UnRegisterUser

func UnRegisterUser(db *sql.DB, username string) error

func UncreateGroup

func UncreateGroup(db *sql.DB, groupName string) error

func ValidateEmail

func ValidateEmail(db *sql.DB, username, email string) error

func ValidateUser

func ValidateUser(db *sql.DB, username, password string) error

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
}
var TheHub *Hub

func New

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

func (*Hub) CurrentServiceIsBroken

func (h *Hub) CurrentServiceIsBroken() bool

func (*Hub) CurrentServiceName

func (h *Hub) CurrentServiceName() string

func (*Hub) Do

func (h *Hub) Do(line, username, password, service string, external 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 '$', and as an expression to be passed to the current service if none of the above hold.

func (*Hub) DoHubCommand

func (h *Hub) DoHubCommand(line string)

func (*Hub) GetAndReportErrors

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

func (*Hub) GetPretty

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

func (*Hub) MakeFilepath

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

func (*Hub) OpenHubFolder

func (h *Hub) OpenHubFolder(hubFolder string)

func (*Hub) Quit

func (h *Hub) Quit()

func (*Hub) Repl

func (h *Hub) Repl()

func (*Hub) SaveAndPropagateHubStore

func (h *Hub) SaveAndPropagateHubStore()

func (*Hub) StartHttp

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

func (*Hub) WriteError

func (h *Hub) WriteError(s string)

func (*Hub) WritePretty

func (h *Hub) WritePretty(s string)

func (*Hub) WriteString

func (h *Hub) WriteString(s string)

Jump to

Keyboard shortcuts

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