diff --git a/src/Post_Meta_Command.php b/src/Post_Meta_Command.php index dc8bea1a..f2bc1c12 100644 --- a/src/Post_Meta_Command.php +++ b/src/Post_Meta_Command.php @@ -27,6 +27,254 @@ class Post_Meta_Command extends CommandWithMeta { protected $meta_type = 'post'; + /** + * List all metadata associated with a post. + * + * ## OPTIONS + * + * + * : ID for the post. + * + * [--keys=] + * : Limit output to metadata of specific keys. + * + * [--fields=] + * : Limit the output to specific row fields. Defaults to id,meta_key,meta_value. + * + * [--format=] + * : Render output in a particular format. + * --- + * default: table + * options: + * - table + * - csv + * - json + * - yaml + * - count + * --- + * + * [--orderby=] + * : Set orderby which field. + * --- + * default: id + * options: + * - id + * - meta_key + * - meta_value + * --- + * + * [--order=] + * : Set ascending or descending order. + * --- + * default: asc + * options: + * - asc + * - desc + * --- + * + * [--unserialize] + * : Unserialize meta_value output. + * + * @subcommand list + * + * @param array{0: string} $args Positional arguments.. + * @param array{keys?: string, fields?: string, format: 'table'|'csv'|'json'|'yaml'|'count', orderby: 'id'|'meta_key'|'meta_value', order: 'asc'|'desc', unserialize?: bool} $assoc_args Associative arguments. + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function list_( $args, $assoc_args ) { + parent::list_( $args, $assoc_args ); + } + + /** + * Get meta field value. + * + * ## OPTIONS + * + * + * : The ID of the post. + * + * + * : The name of the meta field to get. + * + * [--single] + * : Whether to return a single value. + * + * [--format=] + * : Get value in a particular format. + * --- + * default: var_export + * options: + * - var_export + * - json + * - yaml + * --- + * + * @param array{0: string, 1: string} $args Positional arguments. + * @param array{single?: bool, format: 'table'|'csv'|'json'|'yaml'} $assoc_args Associative arguments. + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function get( $args, $assoc_args ) { + parent::get( $args, $assoc_args ); + } + + /** + * Delete a meta field. + * + * ## OPTIONS + * + * + * : The ID of the post. + * + * [] + * : The name of the meta field to delete. + * + * [] + * : The value to delete. If omitted, all rows with key will deleted. + * + * [--all] + * : Delete all meta for the post. + * + * @param array $args Positional arguments. + * @param array{all?: bool} $assoc_args Associative arguments. + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function delete( $args, $assoc_args ) { + parent::delete( $args, $assoc_args ); + } + + /** + * Add a meta field. + * + * ## OPTIONS + * + * + * : The ID of the post. + * + * + * : The name of the meta field to create. + * + * [] + * : The value of the meta field. If omitted, the value is read from STDIN. + * + * [--format=] + * : The serialization format for the value. + * --- + * default: plaintext + * options: + * - plaintext + * - json + * --- + * + * @param array $args Positional arguments. + * @param array{format: 'plaintext'|'json'} $assoc_args Associative arguments. + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function add( $args, $assoc_args ) { + parent::add( $args, $assoc_args ); + } + + /** + * Update a meta field. + * + * ## OPTIONS + * + * + * : The ID of the post. + * + * + * : The name of the meta field to update. + * + * [] + * : The new value. If omitted, the value is read from STDIN. + * + * [--format=] + * : The serialization format for the value. + * --- + * default: plaintext + * options: + * - plaintext + * - json + * --- + * + * @alias set + * + * @param array $args Positional arguments. + * @param array{format: 'plaintext'|'json'} $assoc_args Associative arguments. + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function update( $args, $assoc_args ) { + parent::update( $args, $assoc_args ); + } + + /** + * Get a nested value from a meta field. + * + * ## OPTIONS + * + * + * : The ID of the post. + * + * + * : The name of the meta field to get. + * + * ... + * : The name(s) of the keys within the value to locate the value to pluck. + * + * [--format=] + * : The output format of the value. + * --- + * default: plaintext + * options: + * - plaintext + * - json + * - yaml + * --- + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function pluck( $args, $assoc_args ) { + parent::pluck( $args, $assoc_args ); + } + + /** + * Update a nested value for a meta field. + * + * ## OPTIONS + * + * + * : Patch action to perform. + * --- + * options: + * - insert + * - update + * - delete + * --- + * + * + * : The ID of the post. + * + * + * : The name of the meta field to update. + * + * ... + * : The name(s) of the keys within the value to locate the value to patch. + * + * [] + * : The new value. If omitted, the value is read from STDIN. + * + * [--format=] + * : The serialization format for the value. + * --- + * default: plaintext + * options: + * - plaintext + * - json + * --- + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function patch( $args, $assoc_args ) { + parent::patch( $args, $assoc_args ); + } + /** * Check that the post ID exists * diff --git a/src/Post_Term_Command.php b/src/Post_Term_Command.php index f27040ba..251b875c 100644 --- a/src/Post_Term_Command.php +++ b/src/Post_Term_Command.php @@ -44,4 +44,149 @@ protected function get_object_type() { return $post->post_type; } + + /** + * List all terms associated with a post. + * + * ## OPTIONS + * + * + * : ID for the post. + * + * ... + * : One or more taxonomies to list. + * + * [--field=] + * : Prints the value of a single field for each term. + * + * [--fields=] + * : Limit the output to specific row fields. + * + * [--format=] + * : Render output in a particular format. + * --- + * default: table + * options: + * - table + * - csv + * - json + * - yaml + * - count + * - ids + * --- + * + * ## AVAILABLE FIELDS + * + * These fields will be displayed by default for each term: + * + * * term_id + * * name + * * slug + * * taxonomy + * + * These fields are optionally available: + * + * * term_taxonomy_id + * * description + * * term_group + * * parent + * * count + * + * @subcommand list + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function list_( $args, $assoc_args ) { + parent::list_( $args, $assoc_args ); + } + + /** + * Remove a term from a post. + * + * ## OPTIONS + * + * + * : The ID of the post. + * + * + * : The name of the term's taxonomy. + * + * [...] + * : The slug of the term or terms to be removed from the post. + * + * [--by=] + * : Explicitly handle the term value as a slug or id. + * --- + * default: slug + * options: + * - slug + * - id + * --- + * + * [--all] + * : Remove all terms from the post. + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function remove( $args, $assoc_args ) { + parent::remove( $args, $assoc_args ); + } + + /** + * Add a term to a post. + * + * Append the term to the existing set of terms on the post. + * + * ## OPTIONS + * + * + * : The ID of the post. + * + * + * : The name of the taxonomy type to be added. + * + * ... + * : The slug of the term or terms to be added. + * + * [--by=] + * : Explicitly handle the term value as a slug or id. + * --- + * default: slug + * options: + * - slug + * - id + * --- + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function add( $args, $assoc_args ) { + parent::add( $args, $assoc_args ); + } + + /** + * Set post terms. + * + * Replaces existing terms on the post. + * + * ## OPTIONS + * + * + * : The ID of the post. + * + * + * : The name of the taxonomy type to be updated. + * + * ... + * : The slug of the term or terms to be updated. + * + * [--by=] + * : Explicitly handle the term value as a slug or id. + * --- + * default: slug + * options: + * - slug + * - id + * --- + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function set( $args, $assoc_args ) { + parent::set( $args, $assoc_args ); + } } diff --git a/src/User_Meta_Command.php b/src/User_Meta_Command.php index 344488f6..3d814258 100644 --- a/src/User_Meta_Command.php +++ b/src/User_Meta_Command.php @@ -252,6 +252,77 @@ public function update( $args, $assoc_args ) { parent::update( $args, $assoc_args ); } + /** + * Get a nested value from a meta field. + * + * ## OPTIONS + * + * + * : The user login, user email, or user ID of the user to get metadata for. + * + * + * : The name of the meta field to get. + * + * ... + * : The name(s) of the keys within the value to locate the value to pluck. + * + * [--format=] + * : The output format of the value. + * --- + * default: plaintext + * options: + * - plaintext + * - json + * - yaml + * --- + */ + public function pluck( $args, $assoc_args ) { + // @phpstan-ignore argument.templateType + $args = $this->replace_login_with_user_id( $args ); + parent::pluck( $args, $assoc_args ); + } + + /** + * Update a nested value for a meta field. + * + * ## OPTIONS + * + * + * : Patch action to perform. + * --- + * options: + * - insert + * - update + * - delete + * --- + * + * + * : The user login, user email, or user ID of the user to update metadata for. + * + * + * : The name of the meta field to update. + * + * ... + * : The name(s) of the keys within the value to locate the value to patch. + * + * [] + * : The new value. If omitted, the value is read from STDIN. + * + * [--format=] + * : The serialization format for the value. + * --- + * default: plaintext + * options: + * - plaintext + * - json + * --- + */ + public function patch( $args, $assoc_args ) { + // @phpstan-ignore argument.templateType + $args = $this->replace_login_with_user_id( $args ); + parent::patch( $args, $assoc_args ); + } + /** * Wrapper method for add_metadata that can be overridden in sub classes. * diff --git a/src/User_Term_Command.php b/src/User_Term_Command.php index 3ecc9bb4..397bab72 100644 --- a/src/User_Term_Command.php +++ b/src/User_Term_Command.php @@ -13,4 +13,149 @@ */ class User_Term_Command extends CommandWithTerms { protected $obj_type = 'user'; + + /** + * List all terms associated with a user. + * + * ## OPTIONS + * + * + * : ID for the user. + * + * ... + * : One or more taxonomies to list. + * + * [--field=] + * : Prints the value of a single field for each term. + * + * [--fields=] + * : Limit the output to specific row fields. + * + * [--format=] + * : Render output in a particular format. + * --- + * default: table + * options: + * - table + * - csv + * - json + * - yaml + * - count + * - ids + * --- + * + * ## AVAILABLE FIELDS + * + * These fields will be displayed by default for each term: + * + * * term_id + * * name + * * slug + * * taxonomy + * + * These fields are optionally available: + * + * * term_taxonomy_id + * * description + * * term_group + * * parent + * * count + * + * @subcommand list + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function list_( $args, $assoc_args ) { + parent::list_( $args, $assoc_args ); + } + + /** + * Remove a term from a user. + * + * ## OPTIONS + * + * + * : The ID of the user. + * + * + * : The name of the term's taxonomy. + * + * [...] + * : The slug of the term or terms to be removed from the user. + * + * [--by=] + * : Explicitly handle the term value as a slug or id. + * --- + * default: slug + * options: + * - slug + * - id + * --- + * + * [--all] + * : Remove all terms from the user. + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function remove( $args, $assoc_args ) { + parent::remove( $args, $assoc_args ); + } + + /** + * Add a term to a user. + * + * Append the term to the existing set of terms on the user. + * + * ## OPTIONS + * + * + * : The ID of the user. + * + * + * : The name of the taxonomy type to be added. + * + * ... + * : The slug of the term or terms to be added. + * + * [--by=] + * : Explicitly handle the term value as a slug or id. + * --- + * default: slug + * options: + * - slug + * - id + * --- + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function add( $args, $assoc_args ) { + parent::add( $args, $assoc_args ); + } + + /** + * Set user terms. + * + * Replaces existing terms on the user. + * + * ## OPTIONS + * + * + * : The ID of the user. + * + * + * : The name of the taxonomy type to be updated. + * + * ... + * : The slug of the term or terms to be updated. + * + * [--by=] + * : Explicitly handle the term value as a slug or id. + * --- + * default: slug + * options: + * - slug + * - id + * --- + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found -- Override to provide specific documentation. + public function set( $args, $assoc_args ) { + parent::set( $args, $assoc_args ); + } }