Skip to content

Fail fast if user provides unknown flags #8

Closed

Description

@rauchg

To avoid dangerous and costly mistakes.

Activity

  1. codyzu commented on Oct 20, 2016

    @codyzu
    Contributor

    How do you guys feel about switching from minimist to commander for the options parsing?

    I think this will help with #3, #8, and #9. I think we can have better "fail fast" functionality and more descriptive code by moving to commander. It should remove a lot of the manually verification of options.

    I'm working on an idea for #3 with commander, but I wanted to see if there were any objections before I put together a pull request...

  2. OlliV commented on Oct 20, 2016

    @OlliV
    Contributor

    I have been playing around with commander and it feels pretty good and simple to use. @leo @rauchg what do you think?

  3. leo commented on Oct 20, 2016

    @leo
    Contributor

    Commander might be the industry's most used package for this purpose, but it's actually full of old code and bloated with unnecessary stuff. Let's go with args (like now-serve and list)! 😊

  4. leo commented on Oct 21, 2016

    @leo
    Contributor

    Is anyone interested in switching the project to args? Because that would it make it a lot easier for me to merge now-serve into now. If not, I'll tacke it!

  5. codyzu commented on Oct 21, 2016

    @codyzu
    Contributor

    @leo I worked out a proof of concept locally for #3, but it's independent of the args parser. So I haven't looked yet migrating to args. I don't want to slow you down if you're ready to make that migration.

    I had a question fail fast (this issue and #8) and args. What I saw with how we use minimist and args is that each command checks the flags when it needs them. I guess we can move all of those controls the start of each script to enforce the fail fast. However, the default behavior of commander is to throw an error on invalid args, which I thought might be interesting for these issues. Anyways, I'm not sure if this is open to discussion, but I thought it was worth making that point.

    In any case, I'm wondering if it would be worth decoupling the args parsing from the actual scripts? In theory this would allow us to write tests for the command line parsing (while mocking the lib). IMO this would add a lot of quality and add separation of concerns to the design.

    To answer you question, I would be happy to look at #3 and the fail fast issues. But it seems migrating the args parser needs to be done first. If your ready to do that, you should go for it because I won't have many hours in the next days. If you have higher priorities, I can start working on it when I find those hours. Let me know what works best for you. We can chat more about these points on slack too...

  6. codyzu commented on Nov 30, 2016

    @codyzu
    Contributor

    @leo I've been looking at this again. I'm looking at how it could work with args, but I don't see an obvious way to catch unknown flags. I see minimist has the unknown config param that is called for unknown params, but it's not (yet) propagated into args.

    Am I missing something? Or is this something we would want to add to args?

  7. leo commented on Nov 30, 2016

    @leo
    Contributor

    @codyzu Looks like a great addition to me! Also: leo/args#45

  8. rauchg commented on Nov 30, 2016

    @rauchg
    MemberAuthor

    We started using commander, but for example we didn't have the ability to override quitting to make it wait on the update checker. It's very opinionated and tends to be quite inflexible sometimes.

  9. rauchg commented on Nov 30, 2016

    @rauchg
    MemberAuthor

    tl;DR: I'd rather re-implement checking for unknown flags rather than trade off flexibility

  10. codyzu commented on Nov 30, 2016

    @codyzu
    Contributor

    I assumed there must be a back story behind not using commander. That makes sense.

    Thanks @leo, looks like leo/args#45 is the way to go. I'll look at that first...

  11. rauchg commented on Mar 15, 2018

    @rauchg
    MemberAuthor

    Replaced by #1171

  12. added a commit that references this issue on Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions