publish

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package publish is `anfra publish`: a local repo's files published to its org, as PUBLISH.md (anfra-cloud) describes. The command wires it to the terminal (Env); its messages name the command's flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm

func Confirm(ask Prompt, question string) (yes, ok bool)

Confirm asks a yes-or-no question, no the default.

func Run

func Run(ctx context.Context, dir string, o Options, env Env) error

Run publishes the repo at dir: PUBLISH.md's flow, from file selection to the server's answer. Progress goes to env.ErrOut; the outcome to env.Out.

Types

type Env

type Env struct {
	Out, ErrOut io.Writer
	Ask         Prompt
	// Validate validates the repo here, before anything is sent: showing what
	// fails on its writer, and an error refusing the publish. Always, and again on
	// the server, whose verdict on exactly the published files is the one that
	// publishes (PUBLISH.md §Decisions).
	Validate func(context.Context, io.Writer) error
	// Credential is what every call to the server carries; asked for only once a
	// publish will call it.
	Credential func() (func(*http.Request), error)
	// UserAgent names the CLI and its version, for the server.
	UserAgent string
}

Env is what a publish needs from the command around it.

type Options

type Options struct {
	// Message is what the publish is, for the org's history of the repo; "" is
	// HEAD's commit, in a git repo.
	Message string
	// SetOrg is an org's address to record as the repo's, and publish to.
	SetOrg string
	// DryRun lists the files and stops.
	DryRun bool
	// Yes publishes without asking, though the repo was last published elsewhere.
	Yes bool
	// CreateDataSources adds the data sources the repo uses and the org lacks
	// without asking.
	CreateDataSources bool
}

Options are a publish's choices: the command's flags.

type Prompt

type Prompt func(question string, choices ...string) (choice int, ok bool)

Prompt asks a question with choices, the last one the default (the safe answer), and returns the choice's index; ok is false when nobody can answer it (not a terminal).

Jump to

Keyboard shortcuts

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