Documentation
¶
Overview ¶
Package cli builds the workflow command tree.
Index ¶
- func Execute(args []string, stdout, stderr io.Writer, prompt cmdkit.Prompt, ...) error
- func ExitStatus(err error) int
- func LineReader(input *bufio.Reader, prompts io.Writer) func(prompt string) (string, error)
- func NewRootCmd(prompt cmdkit.Prompt) *cobra.Command
- func NewRootCmdOver(prompt cmdkit.Prompt, run RunInterface, serveAt RunWebAt, ...) *cobra.Command
- func SecretReader(input *os.File, prompts io.Writer) func(prompt string) (string, error)
- func WebDeps(deps tui.Deps) webserver.Deps
- type RunInterface
- type RunWeb
- type RunWebAt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute(args []string, stdout, stderr io.Writer, prompt cmdkit.Prompt, env cmdkit.Environment) error
Execute runs the command tree with the given arguments and streams, in env: the directory, home, variables, store and programs of the process it runs in, which no command reads for itself. A command that fails has its error said once, on stderr, tagged ERROR; Execute returns it rather than exiting, so tests can drive it and the caller can exit with its ExitStatus.
SIGINT and SIGTERM cancel the context every command runs under, which flows to each HTTP request and subprocess: a hung `doctor --online` or a slow git command stops on the first Ctrl+C rather than needing a second, harder signal. The interface handles no signal itself: it puts the terminal in raw mode, where Ctrl+C arrives as a key, which quits it, and a signal ends it through this context, as it ends every other command. Once the last interface has quit, workflow waits, up to timing.request_timeout, for the writes it left in flight; a Ctrl+C then, which the restored terminal sends as SIGINT, or SIGTERM ends those writes' contexts and exits at once, waiting for none.
A little work detaches from its asker's context, bounded, since stopping it halfway would lose what it was for: Settings' refresh of a Slack user token's secrets and their keeping in the keychain (wiring.PlaceSlackCredentials), as Slack spends the old pair when it answers, within timing.request_timeout and security's 30 seconds; and a post's record (loop.Deliver) and the store's open, local SQLite writes that wait at most five seconds for its lock. It runs to its end only where something waits for it, as a command's own call does, and as --web's drain does for a request it serves, within its five-second grace. In the terminal a quit waits, up to timing.request_timeout, for the refresh, which runs inside the settings save it is part of, for a post's record, itself a counted write, and for the store's open when a write to the store begins it, as part of that write; it does not wait for an open a read of the store begins (the announcements, the cached issue list, the last scope), as it waits for no read. A signal exits at once under all of it, and ends a post's record there as it ends every write the interface sends (TRADE-38 says what that can cost).
The editor the interface hands the terminal to runs under no context: it is yours until you leave it, and a signal while it is open ends workflow once you do.
func ExitStatus ¶ added in v0.3.0
ExitStatus is the status the process exits with for err: 0 for none, 130 when it was interrupted, 1 when its output could not be written, and otherwise the first family err belongs to — usage 2, configuration 3, a refused precondition 4, unreachable 5 — or 1 for any other failure. A joined error takes the first family any of its errors is in, in that order.
func LineReader ¶ added in v0.8.0
LineReader is cmdkit.Prompt.Line over input: it prints each prompt to prompts and reads one line from input, without its line ending. A last line typed with no newline after it is an answer, not the end of the input; the read after it is.
func NewRootCmd ¶
NewRootCmd builds the command tree to walk, as the reference generator does: it runs no command, so it is handed no Environment to run one in, and a command run from it anyway says so. The prompt is how `config init` asks for credentials; a zero one is fine.
func NewRootCmdOver ¶ added in v0.3.1
func NewRootCmdOver(prompt cmdkit.Prompt, run RunInterface, serveAt RunWebAt, env cmdkit.Environment) *cobra.Command
NewRootCmdOver builds the command tree over the interface and web server a caller hands it, so a test can see what bare `workflow` and `workflow --web` open without a terminal or a port, and has every command run in env.
func SecretReader ¶ added in v0.9.0
SecretReader is cmdkit.Prompt.Secret over input: it prints each prompt to prompts and reads one line from input without echoing it. Input that is no terminal — a pipe, a file — has no echo to turn off, and Line's buffered reader may already hold what follows its line, so it is answered as the end of the input, which every question words as how to go on without one.
func WebDeps ¶ added in v0.3.0
WebDeps hands the web server the interface's seam groups whole, with the keymap the interface checks and binds, so a seam a group gains reaches the server with no edit here. They are the same seams, which is why the web server is another consumer of the wiring rather than a second implementation.
Types ¶
type RunInterface ¶ added in v0.3.1
type RunInterface func(ctx context.Context, model tui.Model, in io.Reader, out io.Writer) (tui.Next, error)
RunInterface starts the interface and blocks until the user quits, or asks to switch directory, which the Next it returns says. It is tui.Run in production and a fake in tests, so the root command's own wiring — loading the configuration, building the model, applying dry run and color off, and opening the next interface where a switch asks — can be exercised without a real terminal.
type RunWeb ¶ added in v0.3.1
type RunWeb func( ctx context.Context, cfg config.Config, deps webserver.Deps, info webserver.Info, notes io.Writer, ) error
RunWeb starts the local web server and blocks until the context is canceled. What it says about the server goes to notes, stderr: the server has no artifact for stdout to carry.
func WebServerAt ¶ added in v0.3.1
WebServerAt is the web server, built over the seams and served on addr until the context is canceled, under a session it makes as it starts. It says where it serves only once it holds the port, naming the port it bound, so a port another program holds is a failure rather than a claim, and port 0 names the port the system chose; the address it prints carries the session, which only a request that presents it gets past. Production serves only a webserver.LoopbackAddr, through NewRootCmd; a test hands it port 0. The handler reads the configuration file cfg came from once more, so it starts from an edit made since, with that edit's revision. Building it fails when the embedded spec cannot load, a build defect, or when that file cannot be read again. Each failure the server answers as internal goes to notes, a line each, its cause's own lines joined by "; " and every credential masked that the configuration in effect when it failed holds.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package clitest runs the workflow command line for a test, as a user or a script would type it: each run in a world of its own — a working directory, a home and none of the developer's environment but what the test set — with a Jira, a gh or glab, and a Slack or webhook that answer as the test scripts them, the prompts a guided command reads, the repositories the commands run in, made with git itself, and the process readied for the tests by Main.
|
Package clitest runs the workflow command line for a test, as a user or a script would type it: each run in a world of its own — a working directory, a home and none of the developer's environment but what the test set — with a Jira, a gh or glab, and a Slack or webhook that answer as the test scripts them, the prompts a guided command reads, the repositories the commands run in, made with git itself, and the process readied for the tests by Main. |
|
Package cmdkit is what every workflow command is built from, beneath the command tree internal/cli spells: the scriptable contract — the artifact on a checked stdout, what is said about it on stderr, --yes and --dry-run around a write, a mistake in the call as a usage error — and the connection to where a command runs, the environment it reads the process through, the flags every command shares and the prompt that asks the person at the terminal.
|
Package cmdkit is what every workflow command is built from, beneath the command tree internal/cli spells: the scriptable contract — the artifact on a checked stdout, what is said about it on stderr, --yes and --dry-run around a write, a mistake in the call as a usage error — and the connection to where a command runs, the environment it reads the process through, the flags every command shares and the prompt that asks the person at the terminal. |
|
Package console is what a command says on stderr: its notes, warnings and errors, each an entry of one log; with --verbose, a debug line for each request; and, while a command waits on a terminal, the live line of the wait.
|
Package console is what a command says on stderr: its notes, warnings and errors, each an entry of one log; with --verbose, a debug line for each request; and, while a command waits on a terminal, the live line of the wait. |
|
Package doctor is `workflow doctor`: it reports the build, the git repository a directory is in, the external programs workflow uses, where the store keeps its files and the configuration in effect, as prose or as JSON, and, asked to, puts each credential to its service.
|
Package doctor is `workflow doctor`: it reports the build, the git repository a directory is in, the external programs workflow uses, where the store keeps its files and the configuration in effect, as prose or as JSON, and, asked to, puts each credential to its service. |
|
Package issues is the commands over the issue tracker, Jira or the forge's issues: `issues` and `issue`, which read, and `transition`, `assign`, `worklog` and `comment`, which write an issue once its preview is confirmed.
|
Package issues is the commands over the issue tracker, Jira or the forge's issues: `issues` and `issue`, which read, and `transition`, `assign`, `worklog` and `comment`, which write an issue once its preview is confirmed. |
|
Package pr is the pull or merge request's flow on the command line: `workflow pr`, which opens one for the checked-out branch and makes the offers that follow, and `workflow announce`, which tells the team about it, at once or once its CI passes.
|
Package pr is the pull or merge request's flow on the command line: `workflow pr`, which opens one for the checked-out branch and makes the offers that follow, and `workflow announce`, which tells the team about it, at once or once its CI passes. |
|
Package status is `workflow status`: where the work in a repository stands along the loop, read from its branch, its forge, its tracker and the store, printed on one line or as JSON, for the current repository or for each directory named.
|
Package status is `workflow status`: where the work in a repository stands along the loop, read from its branch, its forge, its tracker and the store, printed on one line or as JSON, for the current repository or for each directory named. |