danielbachhuber / wp-cli-present-command

Present a Markdown file as slides.
3 stars 1 forks source link

How to use command #2

Open ecotechie opened 5 years ago

ecotechie commented 5 years ago

What are best practices for using this command?

I was able to run the command by creating a config.yml file under ~/.wp-cli:

require:
  - packages/local/present.php

I've tried running the command with:

vagrant@new:/var/www/public$ wp eval-file present.php README.md --debug
Debug (bootstrap): Fallback autoloader paths: phar://wp-cli.phar/vendor/autoload.php (0.007s)
Debug (bootstrap): Loading detected autoloader: phar://wp-cli.phar/vendor/autoload.php (0.007s)
Debug (commands): Adding command: cache (0.01s)
Debug (commands): Adding command: transient (0.011s)
Debug (commands): Adding command: comment (0.012s)
Debug (commands): Adding command: meta in comment Namespace (0.013s)
Debug (commands): Adding command: menu (0.014s)
Debug (commands): Adding command: item in menu Namespace (0.014s)
Debug (commands): Adding command: location in menu Namespace (0.015s)
Debug (commands): Deferring command: network meta (0.015s)
Debug (commands): Adding command: option (0.016s)
Debug (commands): Adding command: post (0.018s)
Debug (commands): Adding command: meta in post Namespace (0.018s)
Debug (commands): Adding command: term in post Namespace (0.019s)
Debug (commands): Adding command: post-type (0.019s)
Debug (commands): Adding command: site (0.02s)
Debug (commands): Adding command: meta in site Namespace (0.021s)
Debug (commands): Adding command: option in site Namespace (0.021s)
Debug (commands): Adding command: taxonomy (0.022s)
Debug (commands): Adding command: term (0.023s)
Debug (commands): Adding command: meta in term Namespace (0.023s)
Debug (commands): Adding command: user (0.025s)
Debug (commands): Adding command: meta in user Namespace (0.025s)
Debug (commands): Adding command: session in user Namespace (0.026s)
Debug (commands): Adding command: term in user Namespace (0.026s)
Debug (commands): Adding command: network (0.026s)
Debug (hooks): Processing hook "after_add_command:network" with 1 callbacks (0.027s)
Debug (hooks): On hook "after_add_command:network": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 624 (0.027s)
Debug (commands): Adding command: meta in network Namespace (0.027s)
Debug (commands): Adding command: db (0.03s)
Debug (commands): Adding command: plugin (0.033s)
Debug (commands): Adding command: theme (0.034s)
Debug (commands): Adding command: mod in theme Namespace (0.034s)
Debug (commands): Adding command: scaffold (0.036s)
Debug (commands): Adding command: core (0.036s)
Debug (commands): Adding command: verify-checksums in core Namespace (0.037s)
Debug (commands): Adding command: verify-checksums in plugin Namespace (0.037s)
Debug (commands): Adding command: export (0.038s)
Debug (commands): Adding command: config (0.04s)
Debug (commands): Adding command: core (0.042s)
Debug (commands): Adding command: eval (0.042s)
Debug (commands): Adding command: eval-file (0.042s)
Debug (commands): Adding command: import (0.043s)
Debug (commands): Adding command: media (0.045s)
Debug (commands): Adding command: package (0.046s)
Debug (commands): Adding command: cron (0.047s)
Debug (commands): Adding command: event in cron Namespace (0.047s)
Debug (commands): Adding command: schedule in cron Namespace (0.048s)
Debug (commands): Adding command: embed (0.048s)
Debug (commands): Adding command: fetch in embed Namespace (0.049s)
Debug (commands): Adding command: provider in embed Namespace (0.049s)
Debug (commands): Adding command: handler in embed Namespace (0.05s)
Debug (commands): Adding command: cache in embed Namespace (0.05s)
Debug (commands): Adding command: i18n (0.051s)
Debug (commands): Adding command: make-pot in i18n Namespace (0.052s)
Debug (commands): Adding command: make-json in i18n Namespace (0.052s)
Debug (commands): Deferring command: language core (0.053s)
Debug (commands): Deferring command: language plugin (0.053s)
Debug (commands): Deferring command: language theme (0.054s)
Debug (hooks): Immediately invoking on passed hook "after_add_command:site": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/language-command/language-command.php at line 37 (0.054s)
Debug (commands): Adding command: switch-language in site Namespace (0.055s)
Debug (commands): Adding command: language (0.055s)
Debug (hooks): Processing hook "after_add_command:language" with 3 callbacks (0.055s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 624 (0.056s)
Debug (commands): Adding command: core in language Namespace (0.056s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 624 (0.056s)
Debug (commands): Adding command: plugin in language Namespace (0.057s)
Debug (hooks): On hook "after_add_command:language": Closure in file phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/class-wp-cli.php at line 624 (0.057s)
Debug (commands): Adding command: theme in language Namespace (0.058s)
Debug (commands): Adding command: rewrite (0.058s)
Debug (commands): Adding command: rewrite (0.059s)
Debug (commands): Adding command: cap (0.059s)
Debug (commands): Adding command: role (0.06s)
Debug (commands): Adding command: search-replace (0.061s)
Debug (commands): Adding command: server (0.062s)
Debug (commands): Adding command: shell (0.062s)
Debug (commands): Adding command: super-admin (0.063s)
Debug (commands): Adding command: widget (0.063s)
Debug (commands): Adding command: sidebar (0.064s)
Debug (bootstrap): Adding framework command: phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/commands/cli.php (0.064s)
Debug (commands): Adding command: cli (0.065s)
Debug (commands): Adding command: cache in cli Namespace (0.065s)
Debug (bootstrap): Adding framework command: phar://wp-cli.phar/vendor/wp-cli/wp-cli/php/commands/help.php (0.066s)
Debug (commands): Adding command: help (0.066s)
Debug (bootstrap): No readable global config found (0.066s)
Debug (bootstrap): No project config found (0.067s)
Debug (bootstrap): argv: /usr/local/bin/wp eval-file present.php README.md --debug (0.067s)
Debug (bootstrap): ABSPATH defined: /var/www/public/ (0.067s)
Debug (hooks): Processing hook "before_run_command" with 1 callbacks (0.068s)
Debug (hooks): On hook "before_run_command": WP_CLI\Bootstrap\RegisterDeferredCommands->add_deferred_commands() (0.068s)
Debug (bootstrap): Running command: eval-file (0.068s)
Debug (bootstrap): Begin WordPress load (0.071s)
Debug (bootstrap): wp-config.php path: /var/www/public/wp-config.php (0.073s)
Debug (bootstrap): Loaded WordPress (0.599s)
Debug (commands): Adding command: present (0.6s)

Fairly certain I'm missing an easy solution to running the command :smile:

danielbachhuber commented 5 years ago

@ecotechie If you have the package properly loaded, you can simply run:

$ wp present my-presentation.md

It looks like the command is registered... Can you share the Markdown file you're using?

ecotechie commented 5 years ago

Got it working :confetti_ball:

Looking further into it, I now realize you must register the command on one of the yml files using:

require:
  - packages/local/present.php

Right?

Was hoping to be able to just do a quick wp eval-file.... my bad.

danielbachhuber commented 5 years ago

The command should register as soon as the PHP file is loaded: https://github.com/danielbachhuber/wp-cli-present-command/blob/master/present.php#L203

ecotechie commented 5 years ago

How would you load the php file in the command line without first setting the require: in a yml file? Clearly, I'm lacking in skills here :disappointed:

danielbachhuber commented 5 years ago

Sorry, taking a step all of the way back, here's how I was able to get it working locally:

First, I cloned the repository locally:

$ cd ~/.wp-cli
$ git clone git@github.com:danielbachhuber/wp-cli-present-command.git

Second, I edited ~/.wp-cli/config.yml to load the command:

require:
  - wp-cli-present-command/present.php

At this point, I could run wp present and see some output:

$ wp present
usage: wp present <file>

Then you just load your presentation file into the command:

image

The contents of presentation.md is this:

# This is the first presentation slide

It has some text in the body.

***

# This is the second presentation slide

The *** splits the content into multiple slides.

danielbachhuber commented 5 years ago

Oh. If you installed this with wp package install, then the present command wouldn't be registered because there's no autoloader defined.

ecotechie commented 5 years ago

Thanks for all the info!!!

I got it working as you suggested. Cloned with git.

Pretty fun package :smile: I'll provably change some things and get back to you with a pull request (just some additional formatting or such). I hope you don't mind me using it for a WordCamp talk. Giving credit to you of course!

danielbachhuber commented 5 years ago

I got it working as you suggested. Cloned with git.

Glad to hear :)

I'll provably change some things and get back to you with a pull request (just some additional formatting or such)

That'd be great! It'd be really helpful to have a README too. I haven't used this in such a long time that I've mostly forgotten how it works.

I hope you don't mind me using it for a WordCamp talk.

Sounds good, good luck! Let me know how it goes.