Create a small command-line tool named tmt and place it at /app/tmt (make it executable). This tool should implement minimal argument parsing to support the following behavior so the verifier can run:
Functionality to build
Provide a command-line program called tmt (single executable file at /app/tmt).
Implement a top-level subcommand run that accepts an --id option.
If the run subcommand is invoked without selecting a mode, the tool must print an instruction telling the user to pick either "discover" or "execute" and then exit with status code 2.
The message should clearly mention both words (discover and execute) so that a simple grep can find them.
You do not need to implement the full functionality of discover/execute modes — only detect when neither mode was selected and handle that case as described. Reasonable handling of other invocations (e.g., returning 0 or printing a usage) is acceptable.
Expected inputs and outputs
Input: command-line invocation, e.g.:
tmt run --id /some/path
tmt run --id /some/path discover
tmt run --id /some/path execute
Required output when run is invoked without a mode:
Print a short human-readable line that refers to using either discover or execute (must contain both words so it can be grepped).
Exit with status code 2.
Other invocations (with discover or execute provided) may exit 0 (no specific output required for the verifier).
File location and naming
Implement the program as an executable file named /app/tmt.
The file must be executable (chmod +x /app/tmt).
The verifier will execute tmt from a working directory under data, so ensure the program does not assume a specific working directory.
Notes
Keep the implementation simple and portable (a POSIX shell script is sufficient).
Do not rely on external dependencies beyond standard UNIX utilities.
Tests
The following test script will be used to verify your solution:
bash
#!/bin/bash
. /usr/share/beakerlib/beakerlib.sh || exit 1
rlJournalStart
rlPhaseStartSetup
rlRun "run=\$(mktemp -d)" 0 "Create run directory"
rlRun "pushd data"
rlPhaseEnd
rlPhaseStartTest
rlRun -s "tmt run --id $run" 2 "Run the plan"
rlAssertGrep "Use either 'discover' or 'execute'" $rlRun_LOG
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -rf $run" 0 "Remove run directory"
rlPhaseEnd
rlJournalEnd