utils

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindProjectKanukaRoot

func FindProjectKanukaRoot() (string, error)

FindProjectKanukaRoot traverses up directories to find the project's Kanuka root. Returns the path to the project root if found, empty string otherwise. Stops searching when it reaches the user's home directory.

func FormatPaths

func FormatPaths(paths []string) string

FormatPaths formats a slice of paths into a readable string.

func GenerateDeviceName added in v1.0.0

func GenerateDeviceName(existingDeviceNames []string) (string, error)

GenerateDeviceName generates a device name based on the system hostname. It sanitizes the hostname and checks for conflicts with existing device names. If a conflict is found, it appends a number suffix (-2, -3, etc.).

func GetHostname added in v1.0.0

func GetHostname() (string, error)

GetHostname returns the system hostname.

func GetProjectName

func GetProjectName() (string, error)

GetProjectName returns the name of the current project (directory).

func GetUsername

func GetUsername() (string, error)

GetUsername returns the current username.

func IsTTYAvailable added in v1.0.0

func IsTTYAvailable() bool

IsTTYAvailable returns true if /dev/tty (or CON on Windows) is available for reading.

func IsTerminal added in v1.0.0

func IsTerminal() bool

IsTerminal returns true if stdin is a terminal.

func IsValidEmail added in v1.0.0

func IsValidEmail(email string) bool

IsValidEmail checks if the given string is a valid email address format.

func ReadPassphrase added in v1.0.0

func ReadPassphrase(prompt string) ([]byte, error)

ReadPassphrase prompts the user for a passphrase without echoing input. Returns an error if stdin is not a terminal.

func ReadPassphraseFromTTY added in v1.0.0

func ReadPassphraseFromTTY(prompt string) ([]byte, error)

ReadPassphraseFromTTY prompts the user for a passphrase from /dev/tty (or CON on Windows). This is useful when stdin is being used for other input (e.g., piping a private key). Returns an error if /dev/tty cannot be opened.

func ReadStdin added in v1.0.0

func ReadStdin() ([]byte, error)

ReadStdin reads all content from stdin. Returns an error if stdin is empty, is a terminal (no piped data), or cannot be read.

func SanitizeDeviceName added in v1.0.0

func SanitizeDeviceName(name string) string

SanitizeDeviceName sanitizes a device name by removing special characters and converting spaces to hyphens.

Types

This section is empty.

Jump to

Keyboard shortcuts

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