Utility Modules

Helpers Module

Common utility functions.

sshmenuc.utils.helpers.get_context_config_file(name: str) str[source]

Return the local plaintext config path for a given context name.

sshmenuc.utils.helpers.get_context_dir(name: str) str[source]

Return the local cache directory for a given context name.

sshmenuc.utils.helpers.get_contexts_config_path() str[source]

Return the default path for the multi-context registry file.

sshmenuc.utils.helpers.get_current_user() str[source]

Get current username with fallback for Docker/containerized environments.

Tries multiple methods to get the current username: 1. os.getlogin() - works in normal TTY environments 2. os.getenv(‘USER’) - fallback for containers 3. getpass.getuser() - additional fallback 4. ‘user’ - final fallback if all else fails

Returns:

Current username string

sshmenuc.utils.helpers.get_default_config_path() str[source]

Return the default path for the configuration file.

Returns:

Default config file path in user’s home directory

sshmenuc.utils.helpers.get_enc_path(config_path: str) str[source]

Return the path for the local encrypted backup of a config file.

Parameters:

config_path – Path to the plaintext config file.

Returns:

Path with .enc suffix (e.g. ~/.config/sshmenuc/config.json.enc)

sshmenuc.utils.helpers.get_sync_config_path() str[source]

Return the default path for the sync configuration file.

Returns:

Default sync config file path in user’s home directory

sshmenuc.utils.helpers.setup_argument_parser() ArgumentParser[source]

Configure command-line argument parser.

Returns:

Configured ArgumentParser instance

sshmenuc.utils.helpers.setup_logging(loglevel: str)[source]

Configure logging system.

Parameters:

loglevel – Log level string (debug, info, warning, error, critical)

sshmenuc.utils.helpers.validate_host_entry(entry: dict) bool[source]

Validate a host entry.

Parameters:

entry – Host entry dictionary to validate

Returns:

True if entry is valid, False otherwise