Commit 1d271e8377
Unsigned
Layout: unified · split
src/config.rs +17 −14
| @@ -161,27 +161,27 @@ macro_rules! option_getter { | |||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | macro_rules! option { | 163 | macro_rules! option { |
| 164 | (String, $option_name:ident, $description:literal, $default:literal) => { | 164 | (String, $option_name:ident, $description:literal, $default:literal $(,)?) => { |
| 165 | string_create!($option_name, $description, $default); | 165 | string_create!($option_name, $description, $default); |
| 166 | option_getter!(String, $option_name, String); | 166 | option_getter!(String, $option_name, String); |
| 167 | }; | 167 | }; |
| 168 | 168 | ||
| 169 | (bool, $option_name:ident, $description:literal, $default:literal) => { | 169 | (bool, $option_name:ident, $description:literal, $default:literal $(,)?) => { |
| 170 | bool_create!($option_name, $description, $default); | 170 | bool_create!($option_name, $description, $default); |
| 171 | option_getter!(Boolean, $option_name, bool); | 171 | option_getter!(Boolean, $option_name, bool); |
| 172 | }; | 172 | }; |
| 173 | 173 | ||
| 174 | (Integer, $option_name:ident, $description:literal, $default:literal, $min:literal..$max:literal) => { | 174 | (Integer, $option_name:ident, $description:literal, $default:literal, $min:literal..$max:literal $(,)?) => { |
| 175 | integer_create!($option_name, $description, $default, $min, $max, []); | 175 | integer_create!($option_name, $description, $default, $min, $max, []); |
| 176 | option_getter!(Integer, $option_name, i64); | 176 | option_getter!(Integer, $option_name, i64); |
| 177 | }; | 177 | }; |
| 178 | 178 | ||
| 179 | (Enum, $option_name:ident, $description:literal, $out_type:ty) => { | 179 | (Enum, $option_name:ident, $description:literal, $out_type:ty $(,)?) => { |
| 180 | enum_create!($option_name, $description, $out_type); | 180 | enum_create!($option_name, $description, $out_type); |
| 181 | option_getter!(Integer, $option_name, $out_type); | 181 | option_getter!(Integer, $option_name, $out_type); |
| 182 | }; | 182 | }; |
| 183 | 183 | ||
| 184 | (EvaluatedString, $option_name:ident, $description:literal, $default:literal) => { | 184 | (EvaluatedString, $option_name:ident, $description:literal, $default:literal $(,)?) => { |
| 185 | string_create!($option_name, $description, $default); | 185 | string_create!($option_name, $description, $default); |
| 186 | 186 | ||
| 187 | paste::item! { | 187 | paste::item! { |
| @@ -209,7 +209,7 @@ macro_rules! option { | |||
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | macro_rules! section { | 211 | macro_rules! section { |
| 212 | ($section:ident { $($option_name:ident: $option_type:ident {$($option:tt)*}), * }) => { | 212 | ($section:ident { $($option_name:ident: $option_type:ident {$($option:tt)*}), * $(,)? }) => { |
| 213 | paste::item! { | 213 | paste::item! { |
| 214 | pub struct [<$section:camel Section>]<'a>(SectionHandle<'a>); | 214 | pub struct [<$section:camel Section>]<'a>(SectionHandle<'a>); |
| 215 | 215 | ||
| @@ -238,7 +238,7 @@ macro_rules! section { | |||
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | macro_rules! config { | 240 | macro_rules! config { |
| 241 | ($(Section $section:ident { $($option:tt)* }), *) => { | 241 | ($(Section $section:ident { $($option:tt)* }), * $(,)?) => { |
| 242 | pub struct Config(weechat::config::Config); | 242 | pub struct Config(weechat::config::Config); |
| 243 | 243 | ||
| 244 | impl Deref for Config { | 244 | impl Deref for Config { |
| @@ -294,27 +294,30 @@ config!( | |||
| 294 | Section look { | 294 | Section look { |
| 295 | encrypted_room_sign: String { | 295 | encrypted_room_sign: String { |
| 296 | "A sign that is used to show that the current room is encrypted", | 296 | "A sign that is used to show that the current room is encrypted", |
| 297 | "🔒" | 297 | "🔒", |
| 298 | }, | 298 | }, |
| 299 | |||
| 299 | what: EvaluatedString { | 300 | what: EvaluatedString { |
| 300 | "test", | 301 | "test", |
| 301 | "test2" | 302 | "test2", |
| 302 | }, | 303 | }, |
| 304 | |||
| 303 | int_test: Integer { | 305 | int_test: Integer { |
| 304 | "test", | 306 | "test", |
| 305 | 5, | 307 | 5, |
| 306 | 0..10 | 308 | 0..10, |
| 307 | }, | 309 | }, |
| 310 | |||
| 308 | enum_test: Enum { | 311 | enum_test: Enum { |
| 309 | "test", | 312 | "test", |
| 310 | Test | 313 | Test, |
| 311 | }, | 314 | }, |
| 312 | 315 | ||
| 313 | bool_test: bool { | 316 | bool_test: bool { |
| 314 | "description", | 317 | "description", |
| 315 | false | 318 | false, |
| 316 | } | 319 | }, |
| 317 | } | 320 | }, |
| 318 | ); | 321 | ); |
| 319 | 322 | ||
| 320 | impl ConfigHandle { | 323 | impl ConfigHandle { |