Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Remove quotes in HashTables Keys when possible #3

Closed
JohnLeyva opened this issue Jun 18, 2020 · 4 comments
Closed

Remove quotes in HashTables Keys when possible #3

JohnLeyva opened this issue Jun 18, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@JohnLeyva
Copy link

JohnLeyva commented Jun 18, 2020

First of all, very nice work

it will be nice if hashtables keys are not quoted when it is not necessary in order to generate cleaner output.

So it can generate output like the following

@{
  ModuleVersion = '1.0.0.95'
  CompanyName = 'Unknown'
  RequiredModules =
    @{
      ModuleName = 'Microsoft.PowerShell.Utility'
      GUID = '1da87e53-152b-403e-98dc-74d7b4d63d59'
      ModuleVersion = '7.0.0.0'
    },
    @{
      ModuleName = 'YYYYYY'
      GUID = 'AAAAAAAAAAAA'
      ModuleVersion = '1.0.0.94'
    },
  FunctionsToExport = 'XXX'
  CmdletsToExport = @()
  VariablesToExport = '*'
  AliasesToExport = @()
}
@iRon7
Copy link
Owner

iRon7 commented Jun 19, 2020

Thanks for raising this issue.
I am actually not sure about the correct direction for this. I have searched for some guidelines or best practice for this but couldn't find a clear definition. Therefore I have logged an PowerShellPracticeAndStyle issue: Unquoted strings #146.
Depending on the feedback, I will try to implement your request

@iRon7 iRon7 added the enhancement New feature or request label Jun 19, 2020
@mklement0
Copy link

@JohnLeyva, the rules behind whether string keys need quoting and how to determine the need for quoting programmatically is covered in this SO post (@iRon7 himself asked the question and contributed to one of the answers).

@iRon7
Copy link
Owner

iRon7 commented Oct 17, 2020

@mklement0, thanks for the comments, I am currently working on a new version which includes this request, I will release this version soon.

@iRon7 iRon7 self-assigned this Oct 22, 2020
@iRon7
Copy link
Owner

iRon7 commented Nov 1, 2020

I have published a new version (3.3.6) that leaves hash table keys unquoted where possible.
To define which keys can be left unquoted, the regular expression

-cmatch '^[\p{L}\p{Lt}\p{Lm}\p{Lo}_][\p{L}\p{Lt}\p{Lm}\p{Lo}\p{Nd}_]*$'

in the Unquoted key rules and best practices answer from @mklement is used.

@iRon7 iRon7 closed this as completed Nov 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants