feat: Support relays and naddrs sets

This commit introduces support for 'sets', a feature that simplifies
referencing multiple relays or naddrs with a single word.

Sets are stored in the config directory under `n34` as `config.toml` in
`TOML` format. The config path follows the `$XDG_CONFIG_HOME` standard,
defaulting to `$HOME/.config` if unset.

The `n34 sets` command allows managing sets, adding, removing, updating,
or displaying them. When using the main `--relays` flag, a set name can
be provided to automatically expand its relays (an error occurs if the
set contains no relays). Similarly, any command accepting naddrs can
reference a set to extract its naddrs.

Sets can also be merged by updating a set while specifying another
set in `--repo` merges their naddrs, while `--set-relays` merges their
relays. Removal follows the same pattern.

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-06-01 12:00:49 +00:00
parent d6d3f8a52f
commit 4c6578ccb1
19 changed files with 1010 additions and 97 deletions

View File

@@ -15,16 +15,23 @@
// along with this program. If not, see <https://gnu.org/licenses/gpl-3.0.html>.
/// Commands module
mod commands;
pub mod commands;
/// The CLI config
pub mod config;
/// Default lazy values for CLI arguments
pub mod defaults;
/// CLI arguments parsers
pub mod parsers;
/// CLI traits
mod traits;
pub mod traits;
/// Common helper types used throughout the CLI.
pub mod types;
use clap::Parser;
use clap_verbosity_flag::Verbosity;
pub use self::commands::*;
pub use self::config::*;
use self::traits::CommandRunner;
use crate::error::N34Result;