cli

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli provides the connection settings a takt client resolves from flags, the environment and the config file, in that order.

The file is the human path: `takt auth login` writes the token it minted here, because a child process cannot set an environment variable in its parent shell. The environment is the machine path: CI injects TAKT_TOKEN in one line. Flags are the most specific and win over both. Exported so that anyone writing their own takt client can honour the same settings.

Index

Constants

View Source
const DefaultAddress = "http://localhost:7373"

DefaultAddress is where a client connects when nothing names a server.

Variables

This section is empty.

Functions

func Path

func Path(flag string) (string, error)

Path returns where the config file lives: the given --config flag value, what TAKT_CONFIG names, or .takt/config under the home directory. Pointing either at another file is the multi-server and multi-identity answer.

func Write

func Write(path string, config Config) error

Write stores the config file at the given path, creating its directory readable only by the owner and the file the same way, because the file holds a credential.

Types

type Config

type Config struct {
	// The address of the takt server, as a URL.
	Address string `toml:"address"`
	// The token presented as a bearer credential. Empty sends no credential.
	Token string `toml:"token"`
	// The path of a PEM certificate authority file to check the server's
	// certificate against instead of the system roots.
	CACert string `toml:"ca_cert"`
}

The Config type contains the settings a client connects with.

There is no flag for the token, deliberately: a token passed as a flag lands in shell history and process listings for no benefit the other sources lack.

func Load

func Load(path string) (Config, error)

Load reads the config file at the given path, reporting an absent file as the zero Config: a client that never logged in simply has no file yet.

func Resolve

func Resolve(path, address, caCert string) (Config, error)

Resolve returns the settings a client should connect with, taking each field from the most specific source that supplies it: the given flag values, then the TAKT_ADDRESS, TAKT_TOKEN and TAKT_CA_CERT environment variables, then the config file at the given path. An empty flag value means the flag was not given.

The address falls back to DefaultAddress when nothing supplies one, so a client on the same host as its server needs no configuration at all.

Jump to

Keyboard shortcuts

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