Command Autoloading
arc support dynamic loading of subcommands via the Command.autoload()
method.
This allows you to offer your users to option to extend the functionality of your CLI with their own custom commands.
Command.autoload()
can accept an arbitrary number of paths to either files or directories. When given a file, it will attempt to load commands from that file. When given a directory, it will attempt to load every file in that directory. In both cases, if no command is found, it will continue onto the next path rather than erroring.
Example¶
Now we can run the autoload-demo
command, without importing it directly
Overwriting Commands¶
By default, commands that are autloaded can overwrite regular commands.
You can disable this with a configuration option