jborean93 / PSToml

PowerShell TOML Parser and Writer
MIT License
44 stars 6 forks source link

Get-Content Piped Requiring `-Raw` #1

Closed HeyItsGilbert closed 1 year ago

HeyItsGilbert commented 1 year ago

Not sure if this is by design but I noticed that if I try to run the following I get several errors. If I add the -Raw flag to Get-Content it works fine.

Example:

> Get-Content ./.config/starship.toml | ConvertFrom-Toml
Name                           Value
----                           -----
$schema                        https://starship.rs/config-schema.json
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
ConvertFrom-Toml: (1,12) : error : Invalid End-Of-File found for multi-line string
ConvertFrom-Toml: (1,2) : error : Unexpected token `\` for a base key
(1,3) : error : Unexpected token found `uE0B6` (token: `basickey`) while expecting `]` (token: `closebracket`)
(1,8) : error : Unexpected token found `]` (token: `closebracket`) while expecting token `newline`
(1,9) : error : Unexpected token [(] found
(1,12) : error : Expecting `=` after a key instead of :
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
add_newline                    True
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
directory                      {}
style                          bg:#1C4961 fg:white
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
git_branch                     {}
format                         [ $symbol$branch ]($style)
style                          bg:#2F79A1 fg:white
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
git_status                     {}
format                         [ $all_status$ahead_behind ]($style)
style                          bg:#3A95C7 fg:white
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
time                           {}
disabled                       False
format                         [ $time ]($style)
style                          bg:#40A9E0 fg:white
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
username                       {}
disabled                       True
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
ruby                           {}
disabled                       True
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
shell                          {}
disabled                       False
powershell_indicator           
bash_indicator                 
zsh_indicator                  %_
cmd_indicator                  
unknown_indicator              
style                          cyan bold
format                         [$indicator]($style)
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
hostname                       {}
ssh_only                       False
format                         [$ssh_symbol](bold blue) on [$hostname](bold red) 
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
battery                        {}
full_symbol                    🔋
charging_symbol                🔌
discharging_symbol             ⚡
ConvertFrom-Toml: Cannot validate argument on parameter 'InputObject'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
battery                        {[display, System.Collections.Specialized.OrderedDictionary[]]}
threshold                      30
style                          bold red
jborean93 commented 1 year ago

Yea that is true, maybe I should change the behaviour for piping the input to be joined together like ConvertFrom-Json rather than treat it as each individual TOML entry. It would make more sense for this scenario which is probably super common.