PFT::Conf(3)

πŸ“¦ version 1.4.1, in fedora 43, fedora 44

πŸ’– PFT::Conf πŸ’–

okay bestie, so this is a User Contributed Perl Documentation page for PFT::Conf(3) β€” yes it's a Perl module, yes it's giving very "I configure things and I'm good at it" energy, and yes we're gonna walk through the whole thing together. grab a snack πŸ“


✨ NAME ✨

PFT::Conf β€” the configuration parser for PFT, no cap. it parses config. that's the whole job. slay.


🌸 SYNOPSIS 🌸

here's the vibe, in code, verbatim:

    PFT::Conf->new_default()        # Using default
    PFT::Conf->new_load($root)      # Load from conf file in directory
    PFT::Conf->new_load_locate()    # Load from conf file, find directory
    PFT::Conf->new_load_locate($cwd)

    PFT::Conf::locate()             # Locate root
    PFT::Conf::locate($cwd)

    PFT::Conf::isroot($path)        # Check if location exists under path.

    use Getopt::Long;
    Getopt::Long::Configure 'bundling';
    GetOptions(
        PFT::Conf::wire_getopt(\my %opts),
        'more-opt' => \$more,
    );
    PFT::Conf->new_getopt(\%opts);  # Create with command line options

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically: this is the automatic loader and handler for the configuration file of a PFT site. it does the loading, it does the handling. main character behavior honestly πŸ‘‘

the config itself is a simple YAML file with a conventional name. some keys are mandatory, some are optional. and the whole point of this module? it lets you check for the mandatory ones headache free. like, no aspirin needed, we're just that girl.

Many constructors are available, and here they are, described:

πŸ’… new_default

Creates a new configuration based on environment variables and common sense. (yes, common sense is a real input here, iconic.)

The configuration can later be stored on a file with the "save_to" method.

πŸ’… new_load

Loads a configuration file which must already exist. Accepts as an optional argument the name of a directory (not encoded), which defaults on the current directory.

⚠️ This constructor fails with "croak" if the directory does not contain a configuration file. so like, it will simply not be nice about it. πŸ’€

πŸ’… new_load_locate

Works as "new_load", BUT β€” and this is the good part β€” before failing, it makes an attempt to locate the configuration file in the parent directories, up to the root level. it's out here climbing the family tree looking for your config. 🌳

This is handy for launching commands from the command line without worrying on the current directory: it works as long as your cwd is below a PFT root directory. so like, as long as you're somewhere inside the kingdom, it'll find the castle. 🏰

πŸ’… wire_getopt and new_getopt

This is a two-steps constructor meant for command line initializers. cute, right?

An example of usage can be found in the SYNOPSIS section. In short: the auxiliary function "PFT::Conf::wire_getopt" provides a list of ready-to-use options for the "Getopt::Long" Perl module. It expects a hash reference as argument, which will be used as storage for selected options. The "new_getopt" constructor expects as argument the same hash reference. so you hand it the same hash twice and it all just works, we love a consistent queen. 🫢


πŸŽ€ Shared variables πŸŽ€

  • $PFT::Conf::CONF_NAME is a string. It defines the name of the configuration file. that's it, that's the variable, she's simple and she's powerful. ✨

🌈 Utility functions 🌈

πŸ’œ isroot

The "PFT::Conf::isroot" function searches for the configuration file in the given directory path (not encoded).

Returns "undef" if the file was not found, and the encoded file name (according to locale) if it was found. so: undef = nope, encoded name = yep. vibe check complete. βœ…

πŸ’œ locate

The "PFT::Conf::locate" function locates a PFT configuration file.

It accepts as optional parameter a directory path (not encoded), defaulting on the current working directory.

Possible return values:

  • The input directory itself, if the configuration file was found in it;
  • The first encountered parent directory containing the configuration file;
  • "undef" if no configuration file was found, up to the root of all directories.

three possible outcomes, zero ambiguity, we stan a decisive function. πŸ”₯


πŸ‘‘ Methods πŸ‘‘

✨ save_to

Save the configuration to a file. This will also update the inner root reference, so the intsance will point to the saved file. (yes bestie, "intsance" β€” that's what the page says, we're keeping it, character for character, no notes πŸ™ˆ)


🧚 bye bestie 🧚

and that's the whole page!! this documentation comes to you from the User Contributed Perl Documentation, running on perl v5.42.0, dated 2025-07-25. πŸ’–

go forth and configure things. PFT::Conf is rooting for you. periodt. πŸ’…πŸŒˆβ­

πŸ“¦ where this page comes from