support conflicting command names in different module directories
Currently we have commands spread accross different modules/directories of SDB. For example, we have a directory for linux specific commands, zfs specific commands, and spl specific commands:
$ ls sdb/commands/linux
dmesg.py __init__.py internal/ slabs.py
$ ls sdb/commands/spl
avl.py __init__.py internal/ spl_kmem_caches.py spl_list.py
$ ls sdb/commands/zfs
arc.py dbuf.py __init__.py internal/ metaslab.py spa.py vdev.py zfs_dbgmsg.py
Looking spl_list.py, we can see that it defines an spl_list command:
class SPLList(sdb.Walker):
names = ["spl_list"]
The reason the command is named spl_list as opposed to more simply list, is that we intend to have another command(s) for inspecting non-spl lists; e.g. linux kernel lists. If we named the list command in the SPL directory to list, and also wanted the linux kerne list command to be named list, these two names would be indentical and conflict with each other (likely resulting in an error within SDB).
I think we should support "short" names being used in each subdirectory (e.g. in the "spl" and "linux" directories), and avoid name conflicts by automatically adding some sort of "long" name alias for each command that would include the module from which that command belongs. For example, in spl_list.py we could state:
class SPLList(sdb.Walker):
names = ["list"]
and since this class is in the "spl" subdirectory, we could automatically create an alias of spl:list.
Then, if we also had a linux_list.py command like this:
class LinuxList(sdb.Walker):
names = ["list"]
in the "linux" subdirectory, we could automatically create an aleais of linux:list for that command.
Further, when a user has both commands loaded in their SDB session, and they attempt to use the list command, we could emit a warning stating there's two list commands available, so we need the user to be more explicit in their request, and specify either spl:list or linux:list.
Not exactly related but I'm linking the above to issue https://github.com/delphix/sdb/issues/81 in case we want to more properly support the : in linux:list as proper syntax so linux: list or linux : list work the same.