Skip to content

Add basic arg validation - #178

Merged
scribu merged 40 commits into
masterfrom
arg-validation
Oct 12, 2012
Merged

scribu merged 40 commits into
masterfrom
arg-validation

Conversation

@scribu

@scribu scribu commented Oct 8, 2012

Copy link
Copy Markdown
Member

It would be nice if there was a systematic way to check that

  1. all required parameters are passed
  2. no unknown parameters are passed

@scribu

scribu commented Oct 8, 2012

Copy link
Copy Markdown
Member Author

My first though was to have a static get_accepted_args() function on each class:

static function get_accepted_args() {
  return array( 'foo', 'bar' );
}

Since it's not per-method, you can't specify required args, or you can, but verbosely.

So, what I'm thinking of now is to have a @synopsis adnotation:

/**
 * Create a blog in a multisite install.
 *
 * @subcommand create
 * @synopsis --slug=<slug> --title=<Title> [--email=<email>] [--site_id=<site-id>] [--public]
 */
public function create( $args, $assoc_args ) {

The @subcommand tag would be optional.

scribu added 27 commits October 8, 2012 21:42
scribu pushed a commit that referenced this pull request Oct 12, 2012
@scribu
scribu merged commit 6631142 into master Oct 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants