IF Commons GitHub

sql/cli/shell

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 it
interface Command

A command and its options, which the completions are made from.

MemberTypeWhat it is
namestring
helpstring
flagsreadonly { readonly name: string; readonly help: string; readonly values?: readonly string[] | undefined; readonly switch?: true | undefined; }[]
commandsconst
const commands: readonly Command[]

The commands arcactl has.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

envJsonfunction
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 it
const pgoptionsOf: (i: ShellInput) => string

The value of PGOPTIONS the script offers: the search path.

quoteFishconst
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

quoteNuconst
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

quotePosixconst
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

quotePwshconst
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

ShellInputinterface
interface ShellInput

What a script is made from.

MemberTypeWhat it is
shellShell
instance?stringThe instance's name, which is also its libpq service where there is one.
env?stringWhat the instance is for: dev, staging, prod.
schemastring
models?readonly string[]
config?stringThe arca.config.ts the shell is to use.
home?stringThe directory arcactl keeps its settings in.
service?stringThe libpq service (pg_service.conf) that has the host, user and the rest; the password is in libpq's own files.
url?stringA connection URL without a password.
prompt?booleanWhether to add the arca-prompt function.

Imported by 5 tests of the run (5 passed, 0 failed): the library's results

shellScriptfunction
function shellScript(input: ShellInput): Result<string, readonly string[]>

The script for a shell.

ParameterWhat it is
inputwhat 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

variablesOffunction
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

Titles, headings, exports, tables, columns and requirements. Esc closes.