-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feenkcom/gtoolkit#3557] Add GtPharoDebugLogCli
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/GToolkit-Utility-System/EvaluateCommandLineHandler.extension.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,33 @@ | ||
Extension { #name : #EvaluateCommandLineHandler } | ||
|
||
{ #category : #'*GToolkit-Utility-System' } | ||
EvaluateCommandLineHandler >> argumentString [ | ||
|
||
^ (self filterArguments: self arguments) joinUsing: Character space. | ||
] | ||
|
||
{ #category : #'*GToolkit-Utility-System' } | ||
EvaluateCommandLineHandler >> filterArguments: aSequenceableCollection [ | ||
| inputStream | | ||
|
||
inputStream := aSequenceableCollection readStream. | ||
|
||
^ Array streamContents: [ :stream | | ||
[ inputStream atEnd ] whileFalse: | ||
[ | arg | | ||
arg := inputStream next. | ||
(self includeArgument: arg from: inputStream) ifTrue: | ||
[ stream nextPut: arg ] ] ]. | ||
] | ||
|
||
{ #category : #'*GToolkit-Utility-System' } | ||
EvaluateCommandLineHandler >> includeArgument: arg from: inputStream [ | ||
|
||
(#( '--no-quit' '--save' '-e' '--evaluate') includes: arg) ifTrue: [ ^ false ]. | ||
|
||
arg = '--pharoDebugLog' ifTrue: | ||
[ inputStream atEnd ifFalse: [ inputStream next ]. | ||
^ false ]. | ||
|
||
^ true | ||
] |
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,35 @@ | ||
Class { | ||
#name : #GtPharoDebugLogCli, | ||
#superclass : #Object, | ||
#category : #'GToolkit-Utility-System' | ||
} | ||
|
||
{ #category : #initialization } | ||
GtPharoDebugLogCli class >> checkForPharoDebugLog [ | ||
| arguments index filename | | ||
|
||
arguments := Smalltalk argumentsStartingAtIndex: 0. | ||
index := arguments indexOf: '--pharoDebugLog'. | ||
index = 0 ifTrue: [ ^ self ]. | ||
index = arguments size ifTrue: | ||
[ self error: '--pharoDebugLog: no file name supplied' ]. | ||
filename := arguments at: index + 1. | ||
Stdio stdout | ||
<< 'PharoDebug.log filename set to: '; | ||
<< filename; | ||
lf. | ||
Smalltalk logFileName: filename | ||
] | ||
|
||
{ #category : #initialization } | ||
GtPharoDebugLogCli class >> initialize [ | ||
SessionManager default | ||
registerSystemClassNamed: self name | ||
] | ||
|
||
{ #category : #initialization } | ||
GtPharoDebugLogCli class >> startUp: resuming [ | ||
|
||
resuming ifTrue: | ||
[ self checkForPharoDebugLog ] | ||
] |