Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0047-arcactl-init FR-006, 0047-arcactl-init FR-007
arcactl shell (commons data 0047-arcactl-init FR-006, FR-007): the one script a person's shell sources to be ready to use an arca instance: the ARCA_* variables, PGSERVICE and PGOPTIONS so that psql and every libpq tool reach the right instance and schema, a few functions (arca, arca-doctor, arca-psql, arca-use, arca-off), and completions. It is text made from its input alone, for bash, zsh, fish, PowerShell, nushell and POSIX sh; it connects to nothing and writes nothing, so it is safe in a profile, and it never holds a password. Sourcing it twice is the same as once, switching instance replaces what the last one set, and arca-off takes everything away.
A value is quoted by the rules of its shell, so that any text (spaces, quotes, $, backticks, newlines) arrives as it is. PGOPTIONS is the person's where they have set it: it is replaced only where it is empty or was set by this script before.
Source: commons/data/sql/cli/shell.ts
9 of 11 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.
Commandinterfaceno test imports itinterface Command
A command and its options, which the completions are made from.
| Member | Type | What it is |
|---|
name | string | |
help | string | |
flags | readonly { readonly name: string; readonly help: string; readonly values?: readonly string[] | undefined; readonly switch?: true | undefined; }[] | |
const commands: readonly Command[]
The commands arcactl has.
Imported by 5 tests of the run (5 passed, 0 failed): the library's results
function envJson(input: ShellInput): Result<string, readonly string[]>
The variables of an input as JSON, for a shell that cannot evaluate text it is given (nushell's arca-use).
Imported by 5 tests of the run (5 passed, 0 failed): the library's results
pgoptionsOfconstno test imports itconst pgoptionsOf: (i: ShellInput) => string
The value of PGOPTIONS the script offers: the search path.
const quoteFish: (v: string) => string
A value as a single-quoted word in fish, where only a backslash and a quote are escaped inside.
Imported by 5 tests of the run (5 passed, 0 failed): the library's results
const quoteNu: (v: string) => string
A value as a double-quoted string in nushell, with its escapes.
Imported by 5 tests of the run (5 passed, 0 failed): the library's results
const quotePosix: (v: string) => string
A value as a single-quoted word in a POSIX shell (bash, zsh, sh).
Imported by 5 tests of the run (5 passed, 0 failed): the library's results
const quotePwsh: (v: string) => string
A value as a single-quoted string in PowerShell, where a quote is doubled.
Imported by 5 tests of the run (5 passed, 0 failed): the library's results
interface ShellInput
What a script is made from.
| Member | Type | What it is |
|---|
shell | Shell | |
instance? | string | The instance's name, which is also its libpq service where there is one. |
env? | string | What the instance is for: dev, staging, prod. |
schema | string | |
models? | readonly string[] | |
config? | string | The arca.config.ts the shell is to use. |
home? | string | The directory arcactl keeps its settings in. |
service? | string | The libpq service (pg_service.conf) that has the host, user and the rest; the password is in libpq's own files. |
url? | string | A connection URL without a password. |
prompt? | boolean | Whether to add the arca-prompt function. |
Imported by 5 tests of the run (5 passed, 0 failed): the library's results
function shellScript(input: ShellInput): Result<string, readonly string[]>
The script for a shell.
| Parameter | What it is |
|---|
input | what it is made from |
Returns: the script, or every reason it cannot be made
Imported by 5 tests of the run (5 passed, 0 failed): the library's results
function variablesOf(i: ShellInput): readonly (readonly [string, string])[]
The variables a script sets, in order, and what each is.
Imported by 5 tests of the run (5 passed, 0 failed): the library's results