Skip to content

Feature Request: Allow for hiding individual aliases #1859

Open

Description

@Keboo

My current process for renaming aliases looks like the following:

  1. Create a new symbol (lets take an Option for example) with the new aliases I want
  2. Mark the previous symbol IsHidden=true
  3. When executing a command, I am not forced to pull both values and determine which gets precedence despite this really only being a single thing. This also makes doing things like validation more difficult.

Alternatively, I could always modify the help build to hide to aliases that I don't want displayed. However, at present, this would require more code, than the above solution.

What I would like is the ability to mark individual aliases as hidden so that I only have a single symbol to manage.

Activity

  1. KalleOlaviNiemitalo commented on Sep 23, 2022

    @KalleOlaviNiemitalo

    An IdentifierSymbol.AddHiddenAlias(string) method would be discoverable enough for this. No need to complicate the constructors.

    Should the hidden aliases be entirely hidden from completions, typo corrections, and help; or should they be available from completions if the user has already typed part of the hidden alias and there is no other completion? I think I'd prefer hiding them entirely.

    The implementation might then have public IReadOnlyCollection<string> HiddenAliases { get; } and this would be used only in:

    • CommandLineConfiguration.ThrowIfInvalid()
    • Option.HasAliasIgnoringPrefix(string alias)
    • StringExtensions.ValidTokens(this Command command)

    but not in:

    • ArgumentConversionResult.FormatErrorMessage(Argument argument, Type expectedType, string value, LocalizationResources localizationResources)
    • Command.GetCompletions(CompletionContext context)
    • CommandResultExtensions.TryGetValueForOption(this CommandResult commandResult, IValueDescriptor valueDescriptor, out object? value) -- i.e. do not match the hidden aliases to IValueDescriptor.ValueName
    • HelpBuilder.Default.GetIdentifierSymbolUsageLabel(IdentifierSymbol symbol, HelpContext context)
    • Option.GetLongestAlias()
    • ParseResult.GetCompletions(int? position)
    • TypoCorrection.GetPossibleTokens(Command targetSymbol, string token)
  2. added
    enhancement
    on Sep 23, 2022
  3. jonsequitur commented on Sep 23, 2022

    @jonsequitur
    Contributor

    Should the hidden aliases be entirely hidden from completions, typo corrections, and help; or should they be available from completions if the user has already typed part of the hidden alias and there is no other completion? I think I'd prefer hiding them entirely.

    Agreed. So far, IsHidden means it is hidden everywhere.

  4. Keboo commented on Sep 23, 2022

    @Keboo
    MemberAuthor

    Yes I would expect them to be hidden everywhere.

  5. mitchcapper commented on Oct 21, 2022

    @mitchcapper

    Yes given #133 and the seemingly lack of support for considering any case insensitivity say --Start vs --start we add aliases but this clutters up help and tab completion significantly. If we can hide those options that would be great.

  6. added this to the 2.0 GA milestone on Nov 15, 2022
  7. KalleOlaviNiemitalo commented on Mar 31, 2023

    @KalleOlaviNiemitalo

    As dotnet/runtime#68578 is labelled "api-approved", it seems the API is about to be frozen. If hiding individual aliases is not supported in 2.0 GA, can it be implemented later? It will no longer be possible to remove public ICollection<string> Aliases { get; } from CliOption, but perhaps public ICollection<CliAlias> CliAliases { get; } could be added on the side as a more detailed view to the same collection. I just worry that the two properties could be deemed too confusing in API review and then we'd never get the feature.

  8. modified the milestones: 2.0.0, Backlog on Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-APIenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions