Skip to content

Extensible Architecture Discussion

Steven Black edited this page Apr 9, 2022 · 4 revisions

This page serves to help decide the architecture for this project.

The current direction

See Extensible Architecture for Rust, a question I posed in the Rust Programming Language Forum.

πŸ‘‹ Hello everyone! I'm building a new thing and I need some advice on architecture.

I think I want to build a command architecture like git, whereby the base command is extensible with subsequent command modifiers.

To illustrate, there's a cool repo named git-extras 1 wherein you can call (for example) $ git info and that, in turn, delegates to a separately packaged extra named git-info 1. This sort of extensibility in git is really nice. I think I want to make something like this, as opposed to a monolith.

My questions

  • Does anyone know, what is this type of command architecture called?
  • Do you know if there's rust a repository that uses this architecture that I could use as a rough guide?

Thanks to all in advance! πŸ™

The answer from @jameseb7 is brilliant.

That's how cargo works. It's not particularly complex, it just runs the executable cargo-<subcommand> (in ~/.cargo/bin/ or the PATH) when it encounters a subcommand that isn't in the list of built-in commands. You maybe want to start by looking at the function execute_external_subcommand().

So's the answer by Michael-F-Bryan

The mdbook project uses a similar system for plugins. https://github.com/rust-lang/mdBook

Therefore let's build something akin to mdBook.

Clone this wiki locally