Skip to main content

Crate vomit_config

Crate vomit_config 

Source
Expand description

This crate provides a unified config file for all tools that are part of the Vomit project.

It aims to provide configuration options for various aspects of email accounts. Most tools will only need a subset of the available options, but once an account is fully configured, all tools will be able to work with it.

While written for the Vomit project, this is essentially a generic email account configuration library. If you think it might be useful for you feel free to use outside of Vomit.

§File format

Previously, the TOML file format was used. This is still supported, but deprecated in favor of scfg. The library will print a warning to stderr when loading a TOML file. To migrate over, simply change the filename extension from .toml to .scfg and convert it to the format described below.

The standard location is $XDG_CONFIG_DIR/vomit/config.scfg, which usually means ~/.config/vomit/config.scfg.

Projects using this will have their own documentation about which values they require. Here is a sample with all available options (though some commented out), including comments on their usage:

# This section defines one account named "example". Most tools
# support multiple accounts. If not specified, tools should default
# to the first account in the config file.
account example {

    # `local` defaults to "~/.maildir", but is best set explicitly:
    local '/home/test/.mail'

    # The mail server. Must support IMAPS
    remote 'imap.example.com'

    # Login name for the mail server
    user 'johndoe'

    # Password for the mail server. Can be set explicitly:
    #password 'hunter1'
    # but that's not great for security. Instead use a command,
    # e.g. to interact with your password manager
    pass-cmd 'pass show mail/example.com'

    # This section defines settings relevant only for sending mail.
    send {
        # Override the mail server for sending.
        # Defaults to the account-level remote if not set.
        remote 'smtp.example.com'

        # Some mail setups have different credentials for sending,
        # so those can be overridden, too.
        # Defaults to the account-level user if not set.
        user 'johndoe@example.com'

        # See password and pass-cmd above.
        # If neither are set, account-level credentials will be used.
        #password 's3cr3t'
        pass-cmd 'pass show mail/smtp.example.com'

        # The From header of outgoing emails. Defaults to the configured
        # user, but this will only work if the username is a valid email
        # address.
        from 'John Doe <johndoe@example.com>'
    }
}

Structs§

Account
Represents the configuration of a specific account.
Config
Represents a complete config file, which can hold multiple Accounts.

Enums§

ConfigError
An error that can occur while reading the config file.

Functions§

default_path
Returns the (system dependent) default path to the configuration file.
load
Load a configuration file.