Skip to content

Allow [Hidden] on namespace classes; add Help/Schema properties - #77

Open
Mpdreamz wants to merge 2 commits into
mainfrom
fix/hide-on-class
Open

Mpdreamz wants to merge 2 commits into
mainfrom
fix/hide-on-class

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

[Hidden] can now be placed on a namespace handler class to suppress the entire namespace from the help listing. The attribute gains two named properties — Help (default true) and Schema (default false) — giving callers explicit control over whether an item is hidden from users, from tooling, or from both.

Prompt summary: Extend [Hidden] to accept AttributeTargets.Class so a namespace handler type can opt its namespace out of the public --help output. The use-case is internal or automation namespaces (such as a release namespace) that CI scripts should still be able to invoke, but that should not clutter the help listing end users see. As part of this, add Help and Schema named properties so callers can control each surface independently.

Why

Namespaces registered via AddNamespace<T> have no way to suppress themselves from the root or parent help listing short of not registering them at all. Internal automation namespaces end up visible to every end user running --help, even when they are never meant for direct use.

What

Attribute surface

[Hidden] now allows AttributeTargets.Class and exposes two named properties: Help (default true) and Schema (default false). Plain [Hidden] hides an item from the help listing but leaves it fully visible in __schema output. Setting Schema = true is wired through the generator pipeline but has no effect on namespace __schema output yet — see below.

Generator pipeline

A new GetHiddenFlags helper replaces HasHiddenAttribute everywhere in the generator. It returns a (HideHelp, HideSchema) pair by reading the named properties from the attribute. Both flags flow as IsHidden (help gate) and IsHiddenInSchema (schema gate) on CommandModel, ParameterModel, RegistryNode.NamedCommandNamespaceChild, ChildNamespaceSnapshot, and AIMapNamespace.

Help output

The root and namespace help printers now filter child namespaces where IsHidden is true. A hidden namespace is still fully callable — the dispatch router routes to it normally. Only the listing in the parent's --help output is suppressed.

Schema output

The hidden: true flag on commands and parameters now requires an explicit [Hidden(Schema = true)] rather than being emitted by every bare [Hidden]. Existing test fixtures that relied on [Hidden] producing hidden: true in schema are updated to [Hidden(Schema = true)]. The hidden property is NOT yet emitted on namespace objects: the upstream cli-schema meta-schema doesn't define it for namespaces, so adding it caused schema-conformance failures. This is tracked at cli-schema/cli-schema#7.

Verify

dotnet test tests/Nullean.Argh.IntegrationTests/ -c Release --filter "FullyQualifiedName~Hidden"
# RootHelp_does_not_list_hidden_namespaces — namespace with [Hidden] absent from help output
# Hidden_namespace_is_still_callable — hidden namespace still dispatches correctly
# Schema_hidden_namespace_appears_in_schema_without_hidden_flag — [Hidden] alone leaves schema clean

Breaking: [Hidden] on a command method or parameter no longer emits hidden: true in __schema output by default. Use [Hidden(Schema = true)] to restore that behaviour.

Out of scope: hidden on namespace __schema objects is deferred pending the upstream meta-schema change at cli-schema/cli-schema#7. [MiddlewareAttribute<T>] on a class (namespace-level middleware) is also a natural companion but requires non-trivial generator changes and will be addressed separately.

🤖 Generated with Claude Code

… properties

`[Hidden]` now accepts `AttributeTargets.Class` so it can be placed on a
namespace handler type to suppress the entire namespace from help output.
The attribute gains two named properties: `Help` (default `true`) and
`Schema` (default `false`). Plain `[Hidden]` hides the item from the help
listing but leaves it fully visible in `__schema` output. Set
`Schema = true` to also mark it `hidden: true` in the schema so tooling
can suppress it selectively. The command or parameter is always callable,
regardless of either flag.

The generator reads both flags through a new `GetHiddenFlags` helper and
propagates them as `IsHidden` (help gate) and `IsHiddenInSchema` (schema
gate) on `CommandModel`, `ParameterModel`, and the namespace child types
(`RegistryNode.NamedCommandNamespaceChild`, `ChildNamespaceSnapshot`,
`AIMapNamespace`). The root and namespace help printers filter hidden
namespace children from their listings and width calculations.
`CliNamespaceSchema` gains a `Hidden` field and `CliSchemaJsonWriter`
emits it.

Existing fixtures that relied on `[Hidden]` producing `hidden: true` in
schema are updated to `[Hidden(Schema = true)]`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Mpdreamz Mpdreamz added the enhancement New feature or request label Sep 24, 2026
…eta-schema

The cli-schema meta-schema has additionalProperties: false on namespace
objects and does not include hidden as a valid property. Emitting
hidden: true on namespaces caused the schema-conformance CI check to
fail. Remove Hidden from CliNamespaceSchema and its emitters for now.
IsHiddenInSchema on namespace models is retained for when the meta-schema
is updated (tracked at cli-schema/cli-schema#7).
Drop the schema test that expected hidden: true on namespace objects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant