-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a command to update Template sources.
Related to #652
- Loading branch information
Showing
5 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/PharoLauncher-CLI-Tests/PhLTemplateUpdateCliCommandTest.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Class { | ||
#name : #PhLTemplateUpdateCliCommandTest, | ||
#superclass : #PhLTemplatesCliCommandTest, | ||
#category : #'PharoLauncher-CLI-Tests' | ||
} | ||
|
||
{ #category : #tests } | ||
PhLTemplateUpdateCliCommandTest >> testTemplateUpdateShouldSucceed [ | ||
| command workingDir | | ||
|
||
workingDir := FileSystem memory root. | ||
self launcherModel templateRepository: (PhLTemplateGroupRepository newFromGroups: #()). | ||
|
||
PhLTemplateSources useLauncherCoreDir: workingDir during: [ | ||
PhLTemplateSources flush: #() in: workingDir / PhLTemplateSources sourcesFileName. | ||
command := (context arguments: #('launcher' 'template' 'update')) command. | ||
self assert: command pharoLauncherModel templateRepository roots size equals: 0. | ||
|
||
command execute ]. | ||
|
||
"self assertSuccess." | ||
self assert:( workingDir / 'sources.list') exists. | ||
self assert: command pharoLauncherModel templateRepository roots size equals: 8 | ||
] |
37 changes: 37 additions & 0 deletions
37
src/PharoLauncher-CLI/PhLTemplateUpdateCliCommand.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
" | ||
I represent Pharo Template update sub-command invoked from cmd line of Pharo Launcher. | ||
My responsibility is to update the list of templates from the official source. | ||
" | ||
Class { | ||
#name : #PhLTemplateUpdateCliCommand, | ||
#superclass : #PhLTemplateCliCommand, | ||
#category : #'PharoLauncher-CLI-Commands' | ||
} | ||
|
||
{ #category : #'command line - converting' } | ||
PhLTemplateUpdateCliCommand class >> asCliCommand [ | ||
^ self newLauncherCommandSpec: #update | ||
] | ||
|
||
{ #category : #'command execution' } | ||
PhLTemplateUpdateCliCommand >> basicExecute [ | ||
|
||
self registerOnTemplateSourcesUpdate. | ||
PhLPharoTemplateSources fromFile checkForUpdates. | ||
self pharoLauncherModel resetTemplateRepository. | ||
] | ||
|
||
{ #category : #updating } | ||
PhLTemplateUpdateCliCommand >> registerOnTemplateSourcesUpdate [ | ||
|
||
PhLPharoTemplateSources announcer weak | ||
when: PhLSourcesFileUpdateAvailable | ||
send: #updateTemplateSources | ||
to: self. | ||
] | ||
|
||
{ #category : #updating } | ||
PhLTemplateUpdateCliCommand >> updateTemplateSources [ | ||
|
||
PhLPharoTemplateSources fromFile updateSourcesFile | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters