diff --git a/crates/tiny/config.yml b/crates/tiny/config.yml index 2ef594b6..8e2b9777 100644 --- a/crates/tiny/config.yml +++ b/crates/tiny/config.yml @@ -9,6 +9,9 @@ servers: realname: yourname nicks: [tiny_user] + # Whether to auto-connect to this server on startup. Default is true. + # autoconnect: false + # Server alias to show in the tab line. # alias: OFTC diff --git a/crates/tiny/src/config.rs b/crates/tiny/src/config.rs index b045717b..6dbc403c 100644 --- a/crates/tiny/src/config.rs +++ b/crates/tiny/src/config.rs @@ -59,6 +59,10 @@ pub(crate) struct Server

{ #[serde(default)] pub(crate) pass: Option

, + /// Whether to auto-connect to the server + #[serde(default = "default_true")] + pub(crate) autoconnect: bool, + /// User name to be used in connection registration /// If it is not specified, the first nick will be used instead #[serde(default)] @@ -84,6 +88,10 @@ pub(crate) struct Server

{ pub(crate) sasl_auth: Option>, } +fn default_true() -> bool { + true +} + /// Similar to `Server`, but used when connecting via the `/connect` command. #[derive(Clone, Deserialize)] pub(crate) struct Defaults { @@ -324,6 +332,7 @@ impl Config { port, tls, pass, + autoconnect, user, realname, nicks, @@ -369,6 +378,7 @@ impl Config { port, tls, pass, + autoconnect, user, realname, nicks, @@ -490,6 +500,7 @@ mod tests { port: 123, tls: false, pass: None, + autoconnect: true, user: None, realname: "".to_owned(), nicks: vec!["".to_owned()], diff --git a/crates/tiny/src/main.rs b/crates/tiny/src/main.rs index 6cfc1541..f0a28fe7 100644 --- a/crates/tiny/src/main.rs +++ b/crates/tiny/src/main.rs @@ -145,6 +145,10 @@ fn run( let mut clients: Vec = Vec::with_capacity(servers.len()); for server in servers.iter().cloned() { + if server.autoconnect == false { + continue; + } + tui.new_server_tab(&server.addr, server.alias); let tls = server.tls;