nushell/docs/howto_port_a_command_to_engine_p.md
Eli Flanagan de71cbdd43
document engine-p porting (#3868)
* document engine-p porting

See #3390 for all the details.

* use static numbering
2021-08-08 05:57:32 +12:00

1.3 KiB

How To Port Old Engine Syntax to the Latest and Greatest

engine-p

Even in the new codebase of nu things change and we have some old code to clean up. This guide walks you through how to port old engine syntax to engine-p.

  1. change into the commands source directory
cd crates/nu-command/src/
  1. search for old syntax using ripgrep (rg)
rg --type rust --files-with-matches 'ActionStream|run_with_actions'
  1. update the old syntax engine-p syntax
  • For a smaller example PR see #3794
  • For a more involved example PR see #3649

In many cases this is changing the function name and signature. The function name goes from run_with_actions to run. The signature goes from Result<ActionStream, ShellError> to Result<OutputStream, ShellError>.

Sometimes you cannot alter the signature because the command still requires working with ActionStream. open is one example.

  1. commit changes, run the tests, filtered by the command package and section name:
cargo test --features=extra -p nu-command string
  1. PR and bask in the glory of the nu-and-improved codebase.