I’ve run through the source code and cannot find any kind of command line generation code.. I think it’s just for Unit Tests.
I really love this plugin (only started to look into it a few hours ago), but from what I can see, there are very few hooks to allow developers to integrate with it, and also doesn’t seem to be a nice/easy way to setup custom WP CLI commands for it.. That being said, if you wanted a CLI tool to generate the static site. Here’s a working (but crude) script:
class SimplyStaticGenerator
{
public function generate($args = [], $assoc_args = [])
{
$done = $this->perform('start');
while (!$done) {
$done = $this->perform('continue');
}
\WP_CLI::success('Done!');
}
protected function perform($action)
{
$archive_manager = new Simply_Static_Archive_Manager(new Simply_Static_Options(Simply_Static::SLUG));
$archive_manager->perform($action);
$state_name = $archive_manager->get_state_name();
$done = $archive_manager->has_finished();
\WP_CLI::success('In progress..');
return $done;
}
}
if (class_exists('WP_CLI')) {
\WP_CLI::add_command('simply-static', '\SimplyStaticGenerator');
}
I would backup before trying this out. I’ve probably missed something somewhere (as I say, only been looking at the plugin for a few hours, so I was “winging it” when I did this).
@crgeary, how to exactly use that? put it i a new file in the plugin folder? Sorry, I had no chance looing into the wp-cli code and how to wp-cli-ify wp plugins, but know how to ise it and see that many plugins would be great to use with wp-cli, this one is an especially well suited candidate.
wp-cli support is definitely needed for this plugin, would be very cool!
Hi guys,
As crgeary correctly pointed out, WP-CLI is currently only used for unit tests, and isn’t directly integrated with Simply Static. This is definitely something I plan to support eventually, but I don’t have an ETA for it yet.
Best,
Scott