Skip to content

Commit

Permalink
[feenkcom/gtoolkit#3557] Add GtPharoDebugLogCli
Browse files Browse the repository at this point in the history
  • Loading branch information
akgrant43 committed Jan 15, 2024
1 parent f8685ea commit 1da66e5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
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
]
35 changes: 35 additions & 0 deletions src/GToolkit-Utility-System/GtPharoDebugLogCli.class.st
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 ]
]

0 comments on commit 1da66e5

Please sign in to comment.