Skip to content

Commit

Permalink
Added version flag to launcher command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bajger committed Jan 17, 2024
1 parent e3f5848 commit 928c0e9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/PharoLauncher-CLI-Tests/PhLCliCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ PhLCliCommandTest >> testExecuteLauncherCommandToPrintHelp [

]

{ #category : #tests }
PhLCliCommandTest >> testExecuteLauncherCommandToPrintVersion [
|expectedPrintout|
expectedPrintout := PhLAboutCommand new launcherVersion.

self assertCommand: #('launcher' '--version') toPrintHelpWith: expectedPrintout.

]

{ #category : #tests }
PhLCliCommandTest >> testExecuteOSShellCommand [

Expand Down
26 changes: 24 additions & 2 deletions src/PharoLauncher-CLI/PhLCliCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ PhLCliCommand class >> addDelimiterFlagTo: aCommandSpec [
{ #category : #'command line - arguments' }
PhLCliCommand class >> addLauncherFlagsTo: aCommandSpec [

"No positionals on root spec class
use on subclasses e.g.: aCommandSpec addFlag: #someFlag
"Only version flag to launcher commmand.
Use on subclasses e.g.: aCommandSpec addFlag: #someFlag
"
self addVersionFlagTo: aCommandSpec
]

{ #category : #'command line - arguments' }
Expand Down Expand Up @@ -94,6 +95,14 @@ PhLCliCommand class >> addStonFlagTo: aCommandSpec [
description: 'Prints information in STON format.'
]

{ #category : #'command line - arguments' }
PhLCliCommand class >> addVersionFlagTo: aCommandSpec [

aCommandSpec
addFlag: #version
description: 'Prints version of the Pharo Launcher.'
]

{ #category : #'command line - converting' }
PhLCliCommand class >> asCliCommand [
^ self newLauncherCommandSpec: #launcher
Expand Down Expand Up @@ -157,6 +166,7 @@ PhLCliCommand class >> raiseMissingDelimiter [
PhLCliCommand >> basicExecute [

"should be implemented on all sub-classed commands that have business logic, otherwise will print just help"
self hasVersionFlag ifTrue: [ ^ self printVersion ].
self printHelp
]

Expand Down Expand Up @@ -248,6 +258,12 @@ PhLCliCommand >> findLatestPharoStableVersionIn: aTemplateGroup [
^ aTemplateGroup latestStableTemplate
]

{ #category : #'accessing arguments' }
PhLCliCommand >> hasVersionFlag [

^ self hasFlag: #version
]

{ #category : #accessing }
PhLCliCommand >> imageRepository [
^ self pharoLauncherModel imageRepository
Expand Down Expand Up @@ -345,6 +361,12 @@ PhLCliCommand >> printSequence [
^ true
]

{ #category : #printing }
PhLCliCommand >> printVersion [

self logInfoMessage: PhLAboutCommand new launcherVersion
]

{ #category : #'accessing arguments' }
PhLCliCommand >> rowMode [

Expand Down

0 comments on commit 928c0e9

Please sign in to comment.