Skip to content

Improve bit_set support in the flags package#6435

Open
mtarik34b wants to merge 4 commits intoodin-lang:masterfrom
mtarik34b:improve-flags-bitset-support
Open

Improve bit_set support in the flags package#6435
mtarik34b wants to merge 4 commits intoodin-lang:masterfrom
mtarik34b:improve-flags-bitset-support

Conversation

@mtarik34b
Copy link
Contributor

bit_set flags previously required a binary string (0s and 1s). This PR allows using the enum names directly, separated by commas. Binary string options can no longer start with an underscore.

Minimal example:

package named_bitset_flag

import "core:flags"
import "core:fmt"

E :: enum {
	Option_A,
	Option_B,
}

main :: proc() {
	Options :: struct {
		bitset: bit_set[E],
	}
	opt: Options

	args := [?]string {
		"-bitset:Option_B,Option_A"
	}
	flags.parse(&opt, args[:])

	fmt.println(opt.bitset)   // bit_set[E]{Option_A, Option_B}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant