How can you make bitflags mutually exclusive? I have a client/server program that sends files. The client and server are the same program, run in one of two modes. The user chooses which via the command-line. The two modes need to be mutually exclusive. I think the way to do that is to make one of the numbers not a power of two (so if a = 2 and b = 3 then a and b are mutually exclusive) but I'm not entirely sure. Plus, it doesn't work if the flags start at 1 since 1 and 2 are both powers of 2 (20 and 21). The other problem is that I use the bitflags variable for other command-line options and I don't want to affect them.
Like this you'll use a single bit that indicates whether you want the program to be the client or server, and both isn't possible at the same time.
If you also want a mode where the program shall neither be client nor server (i.e. not establish a network connection in any way) you could simply add another flag like that: