question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enhancement: extend command definition with option set

See original GitHub issue

In many commands we have a set of options where we require users to specify value for one of them, eg. in aad app get, we require user to specify appId, objectId or name. In all such cases, we implement validation logic in commands that checks if one of the options has been specified. We also check if only one of these options has been specified and not multiple. We repeat the validation for such options set in all commands. Instead, we should extend the command definition to allow commands to specify option sets. We should then extend the central validation logic, where we check if all required options have been specified, with checking if one option for each option set contains a value and return a relevant error message if that’s not the case.

class Command {
  public optionSets(): string[][] | undefined {
    return;
  }
}
class AadAppGetCommand extends Command {
  public optionSets(): string[][] | undefined {
    return [
      ['appId', 'objectId', 'name']
    ];
  }
}

In the central validation logic we enumerate option sets and check if for each set, one of the specified options has a value. If neither of the options in a set has a value, we return error like Specify either ${options.join(', ')}. If more than one options have a value, we return error like Specify either ${options.join(', ')} but not multiple.

Once we have this logic, we should identify and refactor all commands to define their option sets and remove the obsolete validation logic and tests.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
vipulkelkarcommented, Feb 9, 2022

@waldekmastykarz sure, i will take a look at it

1reaction
waldekmastykarzcommented, Mar 4, 2022

@vipulkelkar for now, let’s use our original idea as we outlined in the spec. We can revisit the schema-based validation in the future as it would be a larger refactoring.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EXTEND (Command) | AutoCAD 2022
Extends the boundary object along its natural path to intersect another object or its implied edge in 3D space. Note: Sets the EDGEMODE...
Read more >
AutoCAD 2021 - Enhancements to “Trim” and “Extend”.
This method of selecting objects when using the “Trim” and “Extend” commands can still be accomplished by selecting the sub command “Cutting ...
Read more >
Using getopts to process long and short command line options
After parsed by getopt , there will not be semicolons. After set -- , dashes and quotes will just be regarded as arguments....
Read more >
PostGraphile | Command Line Interface
Utilities to build powerful and performant GraphQL APIs.
Read more >
Special Commands - Doxygen Manual
When this command is put in a comment block of a function or method and HAVE_DOT is set to YES , then doxygen...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found