mirror of
https://github.com/Smaug123/WoofWare.Myriad
synced 2025-12-15 05:15:40 +00:00
Implements support for --no- prefix negation on boolean and flag DU fields when marked with [<ArgumentNegateWithPrefix>]. This allows both --flag and --no-flag forms to be accepted, with --no- variants negating the value. Changes: - Extend ArgParserGenerator to generate --no- prefix handling - Add conflict detection for overlapping --no- prefixed arguments - Update help text to display both forms (e.g., --verbose / --no-verbose) - Add test examples in ArgParserNegationTests.fs demonstrating: - Boolean field negation - Flag DU negation - Multiple ArgumentLongForm with negation - Combined features (defaults, help text) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
125 lines
3.8 KiB
Forth
125 lines
3.8 KiB
Forth
namespace ConsumePlugin
|
|
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
// This file contains test cases for conflict detection in the ArgParser generator.
|
|
// These are expected to FAIL at build time with appropriate error messages.
|
|
// Uncomment each section one at a time to test the specific conflict detection.
|
|
|
|
// ============================================================================
|
|
// Test 1: Field named NoFooBar conflicts with FooBar's --no- variant
|
|
// ============================================================================
|
|
// Expected error: Argument name conflict: '--no-foo-bar' collides with the --no- variant
|
|
// of field 'FooBar' (which has [<ArgumentNegateWithPrefix>])
|
|
|
|
(*
|
|
[<ArgParser>]
|
|
type ConflictingFieldNames =
|
|
{
|
|
[<ArgumentNegateWithPrefix>]
|
|
FooBar : bool
|
|
NoFooBar : bool
|
|
}
|
|
*)
|
|
|
|
// ============================================================================
|
|
// Test 2: ArgumentLongForm "no-foo" conflicts with Foo's --no- variant
|
|
// ============================================================================
|
|
// Expected error: Argument name conflict: '--no-foo' collides with the --no- variant
|
|
// of field 'Foo' (which has [<ArgumentNegateWithPrefix>])
|
|
|
|
(*
|
|
[<ArgParser>]
|
|
type ConflictingLongForm =
|
|
{
|
|
[<ArgumentNegateWithPrefix>]
|
|
Foo : bool
|
|
[<ArgumentLongForm "no-foo">]
|
|
Bar : bool
|
|
}
|
|
*)
|
|
|
|
// ============================================================================
|
|
// Test 3: Multiple ArgumentLongForm, one conflicts
|
|
// ============================================================================
|
|
// Expected error: Argument name conflict: '--no-verbose' collides with...
|
|
|
|
(*
|
|
[<ArgParser>]
|
|
type ConflictingMultipleLongForms =
|
|
{
|
|
[<ArgumentLongForm "verbose">]
|
|
[<ArgumentLongForm "v">]
|
|
[<ArgumentNegateWithPrefix>]
|
|
VerboseMode : bool
|
|
|
|
[<ArgumentLongForm "no-verbose">]
|
|
Quiet : bool
|
|
}
|
|
*)
|
|
|
|
// ============================================================================
|
|
// Test 4: ArgumentNegateWithPrefix on non-boolean field
|
|
// ============================================================================
|
|
// Expected error: [<ArgumentNegateWithPrefix>] can only be applied to boolean
|
|
// or flag DU fields, but was applied to field NotABool of type string
|
|
|
|
(*
|
|
[<ArgParser>]
|
|
type InvalidAttributeOnNonBool =
|
|
{
|
|
[<ArgumentNegateWithPrefix>]
|
|
NotABool : string
|
|
}
|
|
*)
|
|
|
|
// ============================================================================
|
|
// Test 5: ArgumentNegateWithPrefix on non-flag int field
|
|
// ============================================================================
|
|
// Expected error: [<ArgumentNegateWithPrefix>] can only be applied to boolean
|
|
// or flag DU fields
|
|
|
|
(*
|
|
[<ArgParser>]
|
|
type InvalidAttributeOnInt =
|
|
{
|
|
[<ArgumentNegateWithPrefix>]
|
|
NotAFlag : int
|
|
}
|
|
*)
|
|
|
|
// ============================================================================
|
|
// Test 6: Complex conflict with custom names
|
|
// ============================================================================
|
|
// This tests a more complex scenario where a custom ArgumentLongForm creates
|
|
// a conflict with a different field's negated form
|
|
|
|
(*
|
|
[<ArgParser>]
|
|
type ComplexConflict =
|
|
{
|
|
[<ArgumentLongForm "enable">]
|
|
[<ArgumentNegateWithPrefix>]
|
|
FeatureA : bool
|
|
|
|
[<ArgumentLongForm "no-enable">]
|
|
DisableAll : bool
|
|
}
|
|
*)
|
|
|
|
// ============================================================================
|
|
// Test 7: Valid usage - no conflicts (this SHOULD compile)
|
|
// ============================================================================
|
|
|
|
[<ArgParser>]
|
|
type NoConflict =
|
|
{
|
|
[<ArgumentNegateWithPrefix>]
|
|
EnableFeature : bool
|
|
|
|
[<ArgumentNegateWithPrefix>]
|
|
VerboseMode : bool
|
|
|
|
NormalField : string
|
|
}
|