Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Define short alias names for all keys supported in calculated-property definitions #8430

Closed

Conversation

mklement0
Copy link
Contributor

PR Summary

Implements #8429.

Defines short alias names for all keys supported in calculated-property definitions, so that these aliases can be used safely, without fear of keys introduced in the future making previously unambiguous name prefixes ambiguous.

Note:

  • A single internal class, CalculatedPropertyDefinitionKeys, now defines all supported keys (entries) across all cmdlets, and all future keys should be added there as well.

  • Most alias names are single-character names:

    • l for label
    • n for name
    • e for expression
    • f for formatString
    • d for depth
    • a for alignment
    • w for width
  • The only exceptions:

    • asc for ascending
    • desc for descending

Should the latter two just be a and d too? It's a possibility, given that the conflicting names, d(epth) and a(lignment) only apply to other cmdlets, or is cross-cmdlet consistency more important?

PR Checklist

Defines short alias names for all supported keys,
for unambiguous short alternatives to the full key names.
@mklement0 mklement0 changed the title WIP: [Feature] Define short alias names for all keys supported in calculated-property definitions [Feature] Define short alias names for all keys supported in calculated-property definitions Dec 10, 2018
@iSazonov iSazonov added the Review - Committee The PR/Issue needs a review from the PowerShell Committee label Dec 10, 2018
@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Dec 10, 2018
@stale
Copy link

stale bot commented Jan 10, 2019

This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days.
Thank you for your contributions.
Community members are welcome to grab these works.

@stale stale bot added the Stale label Jan 10, 2019
@joeyaiello
Copy link
Contributor

@PowerShell/powershell-committee had a long discussion on this: a couple of us are ambivalent, and a couple feel like "canonicalizing" these aliases might encourage their usage in scripts (prompting the need to write a PSSA rule that no one wants to write).

Furthermore, no one expects any new keys to be added to this syntax in the future. (Though, personally, I might feel differently if you were planning on adding a host of new keys soon.)

Another possible option would be to add support for tab completion inside of the expression syntax, and everyone agrees that this would solve the meta problem of wanting to be relatively pithy on the command line, even if single-letter collisions occur after the addition of new keys.

@stale stale bot removed the Stale label Jan 16, 2019
@joeyaiello joeyaiello closed this Jan 16, 2019
@joeyaiello joeyaiello added Committee-Reviewed PS-Committee has reviewed this and made a decision and removed Review - Committee The PR/Issue needs a review from the PowerShell Committee labels Jan 16, 2019
@mklement0
Copy link
Contributor Author

Thanks for the feedback, @joeyaiello.

a couple feel like "canonicalizing" these aliases might encourage their usage in scripts

Well, "canonicalizing" these aliases was the primary motivation for this PR: the intent was to future-proof the existing practice of using just n / l and e in scripts, based on a preponderance of such usage online.

Doing so follows the existing practice of providing parameter aliases such as -h for -Hidden in Get-ChildItem and the recently introduced (disclaimer: suggested by yours truly) -lp for -LiteralPath; similarly, the CLI offers -c as an alias for -command, ...

As an aside: Regrettably, these aliases are undocumented.

On a related note: it's worth entertaining a simpler syntax for calculated properties - see #8107


Leaving the alias aspect aside, this PR offered a worthwhile consolidation of all calculated-property keys in a single place, across all cmdlets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Committee-Reviewed PS-Committee has reviewed this and made a decision
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants