Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 39 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -685,46 +685,64 @@ Defaults to all tables registered to the $wpdb database handler.
Displays the database name and size.

~~~
wp db size [--size_format] [--tables] [--format] [--scope=<scope>] [--network] [--all-tables-with-prefix] [--all-tables]
wp db size [--size_format=<format>] [--tables] [--human-readable] [--format=<format>] [--scope=<scope>] [--network] [--all-tables-with-prefix] [--all-tables]
~~~

Display the database name and size for `DB_NAME` specified in wp-config.php.
The size defaults to a human-readable number.

Available size formats include:
* b (bytes)
* kb (kilobytes)
* mb (megabytes)
* gb (gigabytes)
* tb (terabytes)
* B (ISO Byte setting, with no conversion)
* KB (ISO Kilobyte setting, with 1 KB = 1,000 B)
* KiB (ISO Kibibyte setting, with 1 KiB = 1,024 B)
* MB (ISO Megabyte setting, with 1 MB = 1,000 KB)
* MiB (ISO Mebibyte setting, with 1 MiB = 1,024 KiB)
* GB (ISO Gigabyte setting, with 1 GB = 1,000 MB)
* GiB (ISO Gibibyte setting, with 1 GiB = 1,024 MiB)
* TB (ISO Terabyte setting, with 1 TB = 1,000 GB)
* TiB (ISO Tebibyte setting, with 1 TiB = 1,024 GiB)

**OPTIONS**

[--size_format]
[--size_format=<format>]
Display the database size only, as a bare number.
---
default: b
options:
- b (bytes)
- kb (kilobytes)
- mb (megabytes)
- gb (gigabytes)
- tb (terabytes)
- B (ISO Byte setting, with no conversion)
- KB (ISO Kilobyte setting, with 1 KB = 1,000 B)
- KiB (ISO Kibibyte setting, with 1 KiB = 1,024 B)
- MB (ISO Megabyte setting, with 1 MB = 1,000 KB)
- MiB (ISO Mebibyte setting, with 1 MiB = 1,024 KiB)
- GB (ISO Gigabyte setting, with 1 GB = 1,000 MB)
- GiB (ISO Gibibyte setting, with 1 GiB = 1,024 MiB)
- TB (ISO Terabyte setting, with 1 TB = 1,000 GB)
- TiB (ISO Tebibyte setting, with 1 TiB = 1,024 GiB)
---
- b
- kb
- mb
- gb
- tb
- B
- KB
- KiB
- MB
- MiB
- GB
- GiB
- TB
- TiB
---

[--tables]
Display each table name and size instead of the database size.

[--format]
table, csv, json
[--human-readable]
Display database sizes in human readable formats.

[--format=<format>]
Render output in a particular format.
---
default: table
options:
- table
- csv
- json
- yaml
---

[--scope=<scope>]
Expand Down
55 changes: 35 additions & 20 deletions src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,43 +659,58 @@ public function tables( $args, $assoc_args ) {
* Display the database name and size for `DB_NAME` specified in wp-config.php.
* The size defaults to a human-readable number.
*
* Available size formats include:
* * b (bytes)
* * kb (kilobytes)
* * mb (megabytes)
* * gb (gigabytes)
* * tb (terabytes)
* * B (ISO Byte setting, with no conversion)
* * KB (ISO Kilobyte setting, with 1 KB = 1,000 B)
* * KiB (ISO Kibibyte setting, with 1 KiB = 1,024 B)
* * MB (ISO Megabyte setting, with 1 MB = 1,000 KB)
* * MiB (ISO Mebibyte setting, with 1 MiB = 1,024 KiB)
* * GB (ISO Gigabyte setting, with 1 GB = 1,000 MB)
* * GiB (ISO Gibibyte setting, with 1 GiB = 1,024 MiB)
* * TB (ISO Terabyte setting, with 1 TB = 1,000 GB)
* * TiB (ISO Tebibyte setting, with 1 TiB = 1,024 GiB)
*
* ## OPTIONS
*
* [--size_format]
* [--size_format=<format>]
* : Display the database size only, as a bare number.
* ---
* default: b
* options:
* - b (bytes)
* - kb (kilobytes)
* - mb (megabytes)
* - gb (gigabytes)
* - tb (terabytes)
* - B (ISO Byte setting, with no conversion)
* - KB (ISO Kilobyte setting, with 1 KB = 1,000 B)
* - KiB (ISO Kibibyte setting, with 1 KiB = 1,024 B)
* - MB (ISO Megabyte setting, with 1 MB = 1,000 KB)
* - MiB (ISO Mebibyte setting, with 1 MiB = 1,024 KiB)
* - GB (ISO Gigabyte setting, with 1 GB = 1,000 MB)
* - GiB (ISO Gibibyte setting, with 1 GiB = 1,024 MiB)
* - TB (ISO Terabyte setting, with 1 TB = 1,000 GB)
* - TiB (ISO Tebibyte setting, with 1 TiB = 1,024 GiB)
* ---
* - b
* - kb
* - mb
* - gb
* - tb
* - B
* - KB
* - KiB
* - MB
* - MiB
* - GB
* - GiB
* - TB
* - TiB
* ---
*
* [--tables]
* : Display each table name and size instead of the database size.
*
* [--human-readable]
* : Display database sizes in human readable formats.
*
* [--format]
* : table, csv, json
* [--format=<format>]
* : Render output in a particular format.
* ---
* default: table
* options:
* - table
* - csv
* - json
* - yaml
* ---
*
* [--scope=<scope>]
Expand Down