Skip to content

Latest commit

 

History

History
153 lines (102 loc) · 4.93 KB

add-new-sub-command.rst

File metadata and controls

153 lines (102 loc) · 4.93 KB

Add new module sub-command

This document is a guide for Modules developers that wish to introduce a new sub-command for the :command:`module` command.

Core code

Introducing new configuration option means declaring it then using it (get its value then branch code in :file:`modulecmd.tcl` script to adapt :command:`module` command behavior.

  1. First update in the reportUsage procedure the usage message of the :command:`module` command to report the new sub-command.

  2. Update the module procedure and its helper procedures to register the new sub-command. First add sub-command in the list of valid sub-commands defined in parseModuleCommandName.

    If sub-command cannot be called within a modulefile context add it in module procedure to the list of sub-commands raising an error if found call from such context.

    Add test in module procedure to verify that the number of argument passed to sub-command is valid.

    Update main switch in module procedure to add case for new sub-command that calls the cmdModule<Subcmdname> procedure.

  3. Create the cmdModule<Subcmdname> procedure and craft in it the Tcl code corresponding to the sub-command introduced.

Initialization scripts

New sub-command should be referred in the shell completion scripts.

Files that should be edited to add reference to the new sub-command:

Example commit: :ghcommit:`0a96ed64`

Linter scripts

New sub-commands should be described in Nagelfar syntax databases if it can be called within a modulefile context.

Files that should be edited to add reference to the new sub-command:

Documentation

Man pages and other user documentation have to be updated to describe the introduced sub-command.

Files that should be edited:

Example commits:

Testsuite

Non-regression testsuite must be adapted first to add specific tests to check the behavior of the added sub-command and ensure overall code coverage does not drop.

  1. Test the sub-command against an invalid number of arguments (too few and too many).

  2. If the new sub-command cannot be called from a modulefile evaluation, test the error obtained when tried.

  3. If the new sub-command leads to modulefile evaluation, test value returned by :mfcmd:`module-info command<module-info>`.

  4. Craft specific tests to validate the correct behavior of the sub-command against valid or invalid values and valid or invalid environment.