#how to conditionally compile commands

4 messages · Page 1 of 1 (latest)

viral turret
#

Heyho,

i have some commands that are meant for dev purposes (e.g. dropping the internal sqlite database or skipping login on button press).
how do i make sure they won't be compiled for production builds?
i know i could do #[cfg(debug_assertions)] for builder.invoke_handler(...) and do it twice for debug and prod configuration.

ideally, i'd like something like this:

let mut handler = generate_handler![prod_command1, prod_command2];

#[cfg(debug_assertions)]
handler.append(dev_command1, dev_command2);

is there something similar?

(Side note: I am using specta if that influences what I can/cannot do and i don't need to generate specta types for my debug commands)

wraith knoll
#

is there something similar?
nope.

i thought you could use #[cfg] in the "array" macro but seemingly that doesn't work.

#

the thing that makes this so tricky to implement on our side is that the generate_handler command basically converts the list of commands to an enum

viral turret
#

okidoki

thanks either way :)