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:
@@ -102,7 +102,7 @@ impl NostrClient {
|
||||
|
||||
/// Initializes a new [`NostrClient`] instance and connects to the specified
|
||||
/// relays.
|
||||
pub async fn init(options: &CliOptions) -> Self {
|
||||
pub async fn init(options: &CliOptions, relays: &[RelayUrl]) -> Self {
|
||||
let client = Self::new(
|
||||
Client::builder()
|
||||
.signer(Keys::new(
|
||||
@@ -115,7 +115,7 @@ impl NostrClient {
|
||||
.build(),
|
||||
);
|
||||
|
||||
client.add_relays(&options.relays).await;
|
||||
client.add_relays(relays).await;
|
||||
client
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user