Hostfi...Manager(3pm)

πŸ“¦
version 0.09 Β· 2 versions
  • 0.09 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.09 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Hostfile::Manager πŸ’–

okay bestie so this is Hostfile::Manager (the (3pm) perl manual page, yk, the one you keep opening and closing without reading) and it is literally here to manage a hostfile by composing multiple fragments into a whole. no cap. it's giving "modular hosts file energy" and honestly? obsessed. πŸŽ€


✨ NAME ✨

Hostfile::Manager β€” manage a hostfile by composing multiple fragments into a whole. periodt. πŸ’…


🌸 SYNOPSIS 🌸

use Hostfile::Manager;

$manager = Hostfile::Manager->new;
$manager->enable_fragment($fragment_name);
$manager->write_hostfile;

like… three lines and your /etc/hosts situation is handled. main character behavior fr fr. πŸ‘‘


πŸ¦‹ ACCESSORS πŸ¦‹

these are the lil getter/setter besties. pass a value in, set it. pass nothing, get it. iconic.

  • Str path_prefix( [Str $prefix] ) β€” defines the prefix that will be searched for hostfile fragments. it defaults to /etc/hostfiles/ so like, that's where it's gonna go looking. πŸ”
  • Str hostfile_path( [Str $path] ) β€” defines the path to the hostfile to manage. defaults to /etc/hosts. yes, that /etc/hosts. πŸ’€
  • Str hostfile β€” the contents of the hostfile under management. the whole vibe, in a string.
  • HashRef fragments β€” the available hostfile fragments. a hashref, as the name literally says.
  • Array fragment_list β€” a list of the names of available fragments. just the names, not the contents, bestie.
  • Str get_fragment( Str $fragment_name ) β€” the contents of an individual hostfile fragment. hand it a name, it hands you the goods. 🫢

πŸ’… METHODS πŸ’…

  • Hostfile::Manager->new( [\%options] ) β€” create a new manager instance. the available options are path_prefix and hostfile_path, both of which are listed up in the ACCESSORS section (go look, i'll wait πŸ“).
  • Bool write_hostfile β€” write the contents of the hostfile to disk. like, actually commit it. returns a Bool. πŸ’Ύ
  • Bool fragment_enabled( Str $fragment_name ) β€” test whether a named fragment is enabled in the hostfile under management. yes/no, that's it.
  • enable_fragment( Str $fragment_name ) β€” enable a named fragment. ⚠️ heads up though: if the fragment is currently enabled, it will be disabled first, and that nukes any modifications that may have been made out-of-band. so like, out-of-band edits? gone. bye. 😭
  • disable_fragment( Str $fragment_name ) β€” disable a named fragment. simple. clean. slay.
  • toggle_fragment( Str $fragment_name ) β€” enable a fragment if it is disabled, disable it otherwise. the flip-flop. the switch. 🌈
  • Str fragment_status_flag( Str $fragment_name ) β€” returns a string indicating the current status of a named fragment. and the possible strings are:
    • "+" β€” the named fragment is enabled.
    • "*" β€” the named fragment is enabled and has been modified in the sourced hostfile.
    • " " β€” the named fragment is not enabled. (yes that is literally a single space. a whole entire space as a status. we love a subtle queen. ✨)

πŸ“œ LICENSE πŸ“œ

Copyright (c) 2010-11,2018 Anthony J. Mirabella. All rights reserved. this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. so like, go off, but respectfully. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Anthony J. Mirabella <mirabeaj AT gmail DOT com>


and that's the whole page bestie!! πŸ¦‹βœ¨ this was written against perl v5.36.0 and the page itself is dated 2022-11-19 β€” tysm for reading, mwah, go fix your hosts file πŸ’–πŸ’…

πŸ“¦ where this page comes from