Coder Social home page Coder Social logo

Comments (12)

adamabdelhamed avatar adamabdelhamed commented on July 29, 2024

By default, PowerArgs is case insensitive, but there is a way to change it. Can you try to put the [ArgIgnoreCase(false)] attribute on your class and see if that helps? That will force all of your usage to be case sensitive.

It might actually have been a bug that it worked before. I would have expected you to get an InvalidArgDefinitionException, but it looks like my verification code doesn't check for shortcuts that are the same when you ignore case.

from powerargs.

adamabdelhamed avatar adamabdelhamed commented on July 29, 2024

After more investigation, I am sure about this. Your code should have never worked without that attribute. -p and -P are the same. I've already coded a fix that will throw an InvalidArgDefinitionException in this case for my next check in. I'll leave this issue open until then.

Let me know if you have any more questions or suggestions on this issue.

Thanks,
Adam

from powerargs.

alexfalkowski avatar alexfalkowski commented on July 29, 2024

So my first paramater is called Path with arg position of 0 I don't want it to have a shortcut and then I have a parameter called Pattern this is set to shortcut to P. When I add the attribute I get

Duplicate arg options with shortcut P

Is this expected behaviour?

Alex

from powerargs.

adamabdelhamed avatar adamabdelhamed commented on July 29, 2024

You have a few options here.

1 You can add [ArgShortcut(null)] to a property which will mean it has no shortcut. 

2 You can specify a shortcut like [ArgShortcut("pa")] for one and [ArgShortcut("p")] for the other to avoid the conflict.  

3 You can remove the ArgShortcut attributes altogether and let PowerArgs come up with defaults that don't conflict (in this case it will choose "p" for the first property it finds and "pa" for the second).

from powerargs.

alexfalkowski avatar alexfalkowski commented on July 29, 2024

Thanks mate :)

from powerargs.

adamabdelhamed avatar adamabdelhamed commented on July 29, 2024

No problem. This is inspiring me to make sure I flag more of these potential issues in my validation code. Thanks for reporting it.

from powerargs.

alexfalkowski avatar alexfalkowski commented on July 29, 2024

Another thought I had was rather than having ArgShortcut and pass null. Maybe have a class called ArgNoShortcut as I personally hate passing in null. This makes it more explicit.

from powerargs.

adamabdelhamed avatar adamabdelhamed commented on July 29, 2024

I'm not a huge fan of adding additional surface area where it's not needed. What about a middle ground. ArgShortcut could have a constant defined called ArgShortcut.NoShortcut. You could then pass that to the ArgShortcut attribute. It would be as explicit as the ArgNoShortcut class without adding a new type.

from powerargs.

alexfalkowski avatar alexfalkowski commented on July 29, 2024

I'm happy with that just thought it would be less typing with a new type. So the class now would take either an enum or a string?

from powerargs.

adamabdelhamed avatar adamabdelhamed commented on July 29, 2024

Yup. I'm thinking something like [ArgShortcut(ShortcutPolicy.NoShortcut)].

from powerargs.

alexfalkowski avatar alexfalkowski commented on July 29, 2024

Awesome looking forward to it :)

from powerargs.

adamabdelhamed avatar adamabdelhamed commented on July 29, 2024

It's in. ArgShortcutPolicy.NoShortcut,

from powerargs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.