Skip to content

Command Autoloading

arc support dynamic loading of subcommands via the CLI.autoload() method.


# /home/user/
from arc import namespace

timers = namespace("timers")

def test():
    print("I've been autoloaded!")
from arc import CLI

cli = CLI()


Now we can run the timers:test command, without importing it directly

$ python timers:test
I've been autoladed!

CLI.autoload() can accept an arbitrary number of paths to either files or directories. When given a file, it will do as above. 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.


Autoloaded Commands cannot overide commands installed by normal means. This is to prevent a user from accidentally overwriting a part of a tool they where unaware of with their own code.