Early exit with better error message when launching `bst shell --build` on some elements

Summary

When trying to launch a build shell on element kinds like import, stack etc. BuildStream currently gives an error message like: Staged artifacts do not provide command 'sh'. This is not technically incorrect but I think we can do better. For example, since the import element can't have build dependencies (again, it technically can have them today but that's a separate bug), we know that any build shell on an import element is always going to fail with a similar error.

Similarly, stack element never stages anything in the sandbox, and as such, is also going to consistently fail.

It would be nice if BuildStream could report better error messages, something like: 'import' element does not allow build shell access.

Steps to reproduce

# Following steps we are running inside a fresh checkout of BuildStream repository

$ cd doc/examples/first-project
$ bst shell --build hello.bst

Error launching shell: Staged artifacts do not provide command 'sh'

Possible fixes

I can see broadly two ways to achieve this:

  1. Add a new variable like BST_RUN_COMMANDS to Element() class and use that to determine if the plugin supports it.
  2. Define a new method like shell() that the plugins can choose whether or not to implement, and not implementing it would raise a nice error.
Edited by Tristan Van Berkom