Skip to content

Conversation

@RiSKeD
Copy link
Contributor

@RiSKeD RiSKeD commented Jan 6, 2026

This PR introduces command level templating as discussed in #248. The first commit refactors the dutagent with a common entry point for passing args to modules. The second commit makes the concept of a main module optional. The third commit adds command level templating as seen above. The help texts are also improved but still need to be refactored after #191 is resolved.

@RiSKeD RiSKeD force-pushed the feat/command-level-templating branch 3 times, most recently from f8eb458 to eaefaee Compare January 7, 2026 07:44
@RiSKeD RiSKeD requested review from Copilot, jenstopp and llogen and removed request for Copilot January 7, 2026 08:24
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces command-level templating functionality, allowing commands to declare named arguments that can be distributed to modules via ${arg-name} template syntax. The changes refactor the "main module" concept to "interactive module" to better reflect its purpose, and make having an interactive module optional when using command-level arguments.

Key changes:

  • Adds Args field to Command struct for declaring named command arguments with positional mapping
  • Renames Main to Interactive in ModuleConfig to clarify the module's role
  • Implements template substitution using os.Expand with validation of template references during configuration parsing

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/dut/dut.go Core implementation: adds ArgDecl struct, template validation and substitution logic, renames Main to Interactive, updates error definitions
pkg/dut/dut_test.go Comprehensive test coverage for template validation, extraction, and substitution with various edge cases
cmds/dutagent/states.go Refactors module execution: adds getModuleArgs for unified argument distribution, extracts runModules function, adds runtime validation for argument requirements
cmds/dutagent/states_test.go Updates test cases to use Interactive instead of Main, renames variables for consistency
cmds/dutagent/rpc.go Updates buildCommandHelp to handle commands without interactive modules and append command args documentation
docs/dutagent-config.md Updates schema documentation to reflect interactive field and new command-level args capability
docs/command-arg-templating.md New comprehensive guide explaining three argument approaches: non-interactive, interactive, and templating with examples
contrib/dutagent-cfg-example.yaml Demonstrates new templating feature with file-transfer command example
pkg/module/*/*-example-cfg.yml Updates all module examples from main: true to interactive: true
cmds/exp/contrib/config-*.yaml Updates experimental config files to use interactive instead of main

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RiSKeD RiSKeD force-pushed the feat/command-level-templating branch 3 times, most recently from 86ab59d to f3754a7 Compare January 7, 2026 08:49
@RiSKeD RiSKeD requested a review from Copilot January 7, 2026 09:37
@RiSKeD RiSKeD requested a review from sylv-io January 7, 2026 09:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RiSKeD RiSKeD force-pushed the feat/command-level-templating branch from f3754a7 to 346a3aa Compare January 7, 2026 09:49
@RiSKeD
Copy link
Contributor Author

RiSKeD commented Jan 7, 2026

@jenstopp One thing i noticed when working on this is that the dut.go file/pkg handles a lot of concerns. Unmarshalling of the config, All the command, module, and dut functions too. Long-term it might be better to separate these concerns into multiple packages.

@RiSKeD RiSKeD force-pushed the feat/command-level-templating branch from 346a3aa to 5ef97b3 Compare January 7, 2026 11:01
@RiSKeD RiSKeD requested a review from Copilot January 7, 2026 12:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@llogen llogen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have nothing to complain about. Looks very clean and straight forward to me

@RiSKeD
Copy link
Contributor Author

RiSKeD commented Jan 7, 2026

Tested this on the internal board with an updated config using all methods.

@RiSKeD RiSKeD force-pushed the feat/command-level-templating branch 5 times, most recently from 76cb0db to 95a4824 Compare January 8, 2026 10:04
@RiSKeD RiSKeD force-pushed the feat/command-level-templating branch from 95a4824 to f0de77e Compare January 8, 2026 10:09
@RiSKeD RiSKeD requested a review from Copilot January 8, 2026 10:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Extract args distribution logic into getModuleArgs function and
pass runtime args explicitly to runModules goroutine, creating a
single unified point for args consumption.

Signed-off-by: Fabian Wienand <fabian.wienand@9elements.com>
Main modules are now optional. Commands can have 0 or 1 main modules instead of
requiring exactly 1.Arguments are only passed to commands that have a main module
else they are ignored with a validation error.

Signed-off-by: Fabian Wienand <fabian.wienand@9elements.com>
Updated terminology from "main module" to "interactive module" to better reflect
the module's purpose of receiving runtime arguments.

Signed-off-by: Fabian Wienand <fabian.wienand@9elements.com>
@RiSKeD RiSKeD force-pushed the feat/command-level-templating branch from f0de77e to 44a2072 Compare January 22, 2026 13:48
Commands can now declare named arguments and distribute them to modules
using ${argname} template syntax. This enables sharing arguments across
multiple modules in a command.

Signed-off-by: Fabian Wienand <fabian.wienand@9elements.com>
@RiSKeD RiSKeD force-pushed the feat/command-level-templating branch from 44a2072 to 4bd25a5 Compare January 22, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants