snivilised / cobrass

🐲 Assistant for cli applications using cobra
https://pkg.go.dev/github.com/snivilised/cobrass
MIT License
1 stars 0 forks source link

create a more user friendly acceptable value error message #162

Closed plastikfan closed 1 year ago

plastikfan commented 1 year ago

Currently, when an enum validation failure occurs, then retuned message looks something like this:

------------------------------
• [FAILED] [0.004 seconds]
ShrinkCmd ShrinkCmd [It] 🧪 ===> given: 'vanilla with long form options'
/home/plastikfan/dev/github/go/snivilised/pixa/src/app/command/shrink-cmd_test.go:102

  [FAILED] should pass validation due to all flag being valid
  Expected
      <i18n.InvalidModeError>:
      invalid mode value: tid, acceptable: === (TYPE: *assistant.EnumInfo[github.com/snivilised/pixa/src/app/magick.ModeEnum]) ===
      --- [tidy] => [tidy] (1) ---
      --- [t] => [tidy] (1) ---
      --- [preserve] => [preserve] (2) ---
      --- [p] => [preserve] (2) ---

      {
          LocalisableError: {
              Data: <i18n.ShrinkCmdModeInvalidTemplData>{
                  pixaTemplData: {},
                  Value: "tid",
                  Acceptable: "=== (TYPE: *assistant.EnumInfo[github.com/snivilised/pixa/src/app/magick.ModeEnum]) ===\n--- [tidy] => [tidy] (1) ---\n--- [t] => [tidy] (1) ---\n--- [preserve] => [preserve] (2) ---\n--- [p] => [preserve] (2) ---\n",
              },
          },
      }
  to be nil
  In [It] at: /home/plastikfan/dev/github/go/snivilised/pixa/src/app/command/shrink-cmd_test.go:46 @ 04/26/23 19:21:26.858
------------------------------

This is not very user friendly, so needs to be improved.

plastikfan commented 1 year ago

... and actually, the EnumProvider isn't really needed (its just a pseudonym for EnumInfo). Any functionality that it contains should be on the EnumInfo so that will be addressed also in this issue