-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Implement -version parameter in console host (address part of https:/… #3115
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -316,6 +316,14 @@ internal bool ServerMode | |
| } | ||
| } | ||
|
|
||
| internal bool ShowVersion | ||
| { | ||
| get | ||
| { | ||
| return _showVersion; | ||
| } | ||
| } | ||
|
|
||
| internal Serialization.DataFormat OutputFormat | ||
| { | ||
| get | ||
|
|
@@ -500,7 +508,6 @@ private void ParseHelper(string[] args) | |
|
|
||
| // chop off the first character so that we're agnostic wrt specifying / or - | ||
| // in front of the switch name. | ||
|
|
||
| switchKey = switchKey.Substring(1); | ||
|
|
||
| // chop off the second dash so we're agnostic wrt specifying - or -- | ||
|
|
@@ -509,6 +516,18 @@ private void ParseHelper(string[] args) | |
| switchKey = switchKey.Substring(1); | ||
| } | ||
|
|
||
| // If version is in the commandline, don't continue to look at any other parameters | ||
|
||
| if (MatchSwitch(switchKey, "version", "v")) | ||
| { | ||
| _showVersion = true; | ||
| _showBanner = false; | ||
| _noInteractive = true; | ||
| _skipUserInit = true; | ||
| _noExit = false; | ||
| break; | ||
| } | ||
|
|
||
|
|
||
| if (MatchSwitch(switchKey, "help", "h") || MatchSwitch(switchKey, "?", "?")) | ||
| { | ||
| _showHelp = true; | ||
|
|
@@ -1091,6 +1110,7 @@ private bool CollectArgs(string[] args, ref int i) | |
| private bool _serverMode; | ||
| private bool _namedPipeServerMode; | ||
| private bool _sshServerMode; | ||
| private bool _showVersion; | ||
| private string _configurationName; | ||
| private PSHostUserInterface _hostUI; | ||
| private bool _showHelp; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,6 +164,18 @@ Describe "ConsoleHost unit tests" -tags "Feature" { | |
| $actual | Should Be $expected | ||
| } | ||
|
|
||
| It "-Version should return the engine version" { | ||
| $currentVersion = "powershell " + $PSVersionTable.GitCommitId.ToString() | ||
| $observed = & $powershell -version | ||
| $observed | should be $currentVersion | ||
| } | ||
|
|
||
| It "-Version should ignore other parameters" { | ||
| $currentVersion = "powershell " + $PSVersionTable.GitCommitId.ToString() | ||
| $observed = & $powershell -version -command get-date | ||
|
||
| # no extraneous output | ||
| $observed | should be $currentVersion | ||
| } | ||
| } | ||
|
|
||
| Context "Pipe to/from powershell" { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not simple
{ get; private set; }#WontFixUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to follow the existing code pattern here. We can convert the style using a tool later. #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to match the current code style
In reply to: 100213197 [](ancestors = 100213197)