Skip to content

Require a target language for interface generation - #47

Merged
glopesdev merged 1 commit into
harp-tech:mainfrom
glopesdev:generate-interface-arguments
Sep 17, 2026
Merged

glopesdev merged 1 commit into
harp-tech:mainfrom
glopesdev:generate-interface-arguments

Conversation

@glopesdev

Copy link
Copy Markdown
Contributor

generate interface declared the device metadata as a positional argument on the parent command and the target language as a subcommand, so the only accepted order was the path followed by the language. Typing the language first would print Unrecognized command or argument 'nope.yml' followed by File does not exist: 'device.yml', naming a file that was never typed.

System.CommandLine makes options recursive but not arguments, so a shared argument has to sit on the parent, and a parent argument has to be consumed before the subcommand token. The order was forced by where the argument was originally declared.

MetadataPathArgument and OutputPathOption are now constructed inside csharp and python, and the parent keeps no argument, no options and no action. The natural order works, and the path stays optional, still defaulting to device.yml in the current directory.

dotnet harp.toolkit generate interface csharp path/to/device.yml
dotnet harp.toolkit generate interface python path/to/device.yml

Naming the language is now required

generate interface with no language generated the .NET interface. It now reports Required command was not provided. with the help listing both targets, and exits 1. No compatibility shim is available, since a default action cannot be hidden the way the firmware path option was hidden in 1bb814b.

The .NET and Python targets are equals now that Harp Python is a first-class target.

Options are declared per target

--namespace was declared on the parent with Recursive = true and then rejected on python by a hand-written validator. python now declares no such option, so --help states the options that apply to each target and the validator is gone. The error for --namespace on Python is correspondingly the parser default, which reads the option as the metadata path and reports a missing file. generate firmware already answers an undeclared option the same way.

The parent description also described the C# output, "Generate reactive programming API and async API", including an async API the Python target does not generate. It now reads "Generate device interface code for a target language", and csharp carries the original text.

The metadata argument is renamed from metadataPath to metadata, matching verify --metadata and naming the content rather than the kind of value.

docs/README.md and docs/articles/generate.md are updated for the new order and for the removed default.

The metadata argument and output option are now declared on the csharp
and python commands rather than on their parent, so the target language
is named before the metadata path. Naming the language is now required,
so generate interface reports that a command was not provided instead
of generating the .NET interface.

The python command no longer declares a --namespace option, so help
states the options that apply to each target and the validator
rejecting the option is gone. The metadata argument is renamed from
metadataPath to metadata.
@glopesdev glopesdev added the feature New planned feature label Sep 17, 2026
@glopesdev
glopesdev merged commit 85f2307 into harp-tech:main Sep 17, 2026
9 checks passed
@glopesdev
glopesdev deleted the generate-interface-arguments branch September 17, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New planned feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant