Skip to content

Commit

Permalink
Take into account code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Apr 19, 2024
1 parent 89f625f commit ecdc1b4
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion docs/explanation/Application-start-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ the logging infrastructure:
`stdout` on Unix); because there's no way to access the `stderr` handle
attached to the VM process.

As a second step, it instantiates a `LaunchpadCommandLineProcessingContext` with
As a second step, it instantiates a `LaunchpadApplicationStartingContext` with
the command-line and a reference to `stdout`. This context is later available
in all the required methods and ultimately accessible by the application in its
`basicStartWithin:` method.
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ $ launchpad start greeter
--dry-run
Perform a dry run of the application.
All the configuration will be loaded (and validated),
but the application will not perform any changes.
but the application will not start.
```

- `debug-mode` Enable the debugging mode.
Expand All @@ -296,4 +296,4 @@ $ launchpad start greeter
- `--enable-structured-logging` Enable structured logging. When enabled the log
will be emitted in JSON format.
- `--dry-run` Perform a dry run of the application. All the configuration will
be loaded (and validated), but the application will not perform any changes.
be loaded (and validated), but the application will not start.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"
A LaunchpadApplicationDryRunContextTest is a test class for testing the behavior of LaunchpadApplicationDryRunContext
"
Class {
#name : 'LaunchpadApplicationDryRunContextTest',
#superclass : 'TestCase',
#category : 'Launchpad-Commands-Tests',
#package : 'Launchpad-Commands-Tests'
}

{ #category : 'tests' }
LaunchpadApplicationDryRunContextTest >> testConverting [

| context |

context := LaunchpadApplicationDryRunContext handling: ( CommandLineArguments withArguments: #( ) ).

self assert: context asDryRunContext equals: context
]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LaunchpadRootCommandTest >> assertCommandCanHandleNextArgumentIn: context [
{ #category : 'private' }
LaunchpadRootCommandTest >> contextWithArguments: arguments writingTo: outputStream [

^ LaunchpadCommandLineProcessingContext handling: ( CommandLineArguments withArguments: arguments )
^ LaunchpadApplicationStartingContext handling: ( CommandLineArguments withArguments: arguments )
writingTo: outputStream
]

Expand Down Expand Up @@ -92,9 +92,9 @@ LaunchpadRootCommandTest >> expectedStartHelpOutput [

^ (self existsExtendedStartingOptions
ifTrue: [
'NAME<n> launchpad-start - Start the selected application<n>SYNOPSYS<n> launchpad start [--help|-h] [--debug-mode] [--settings-file=%<filename>] [--enable-structured-logging] [--dry-run] [--enable-tcp-command-server=%<listeningPort>] %<app> [%<parameters>]<n>DESCRIPTION<n> Start the application selected via %<app>.<n><n><t><t>Application configuration is made by the command-line via %<parameters>, using environment variables or settings files.<n><n><t><t>Execute launchpad explain %<app> to get a list of valid configuration parameters.<n>OPTIONS<n> -h, --help<n> Print this help message and exit.<n> --debug-mode<n> Enable the debugging mode. The image will not quit on unexpected errors. This configuration can be used in the application to improve the debugging experience.<n> --settings-file=%<filename><n> Provide application configuration via a settings file. This option can occur several times to configure more than one settings file. Supported file settings formats are INI and JSON.<n> --enable-structured-logging<n> Enable structured logging. When enabled the log will be emitted in JSON format.<n><t><t>--dry-run<n><t><t><t>Perform a dry run of the application. All the configuration will be loaded (and validated), but the application will not perform any changes.<n> --enable-tcp-command-server=%<listeningPort><n> Enable a TCP command server. This can be used to send commands controlling the application using a TCP port.<n>' ]
'NAME<n> launchpad-start - Start the selected application<n>SYNOPSYS<n> launchpad start [--help|-h] [--debug-mode] [--settings-file=%<filename>] [--enable-structured-logging] [--dry-run] [--enable-tcp-command-server=%<listeningPort>] %<app> [%<parameters>]<n>DESCRIPTION<n> Start the application selected via %<app>.<n><n><t><t>Application configuration is made by the command-line via %<parameters>, using environment variables or settings files.<n><n><t><t>Execute launchpad explain %<app> to get a list of valid configuration parameters.<n>OPTIONS<n> -h, --help<n> Print this help message and exit.<n> --debug-mode<n> Enable the debugging mode. The image will not quit on unexpected errors. This configuration can be used in the application to improve the debugging experience.<n> --settings-file=%<filename><n> Provide application configuration via a settings file. This option can occur several times to configure more than one settings file. Supported file settings formats are INI and JSON.<n> --enable-structured-logging<n> Enable structured logging. When enabled the log will be emitted in JSON format.<n><t><t>--dry-run<n><t><t><t>Perform a dry run of the application. All the configuration will be loaded (and validated), but the application will not start.<n> --enable-tcp-command-server=%<listeningPort><n> Enable a TCP command server. This can be used to send commands controlling the application using a TCP port.<n>' ]
ifFalse: [
'NAME<n> launchpad-start - Start the selected application<n>SYNOPSYS<n> launchpad start [--help|-h] [--debug-mode] [--settings-file=%<filename>] [--enable-structured-logging] [--dry-run] %<app> [%<parameters>]<n>DESCRIPTION<n> Start the application selected via %<app>.<n><n><t><t>Application configuration is made by the command-line via %<parameters>, using environment variables or settings files.<n><n><t><t>Execute launchpad explain %<app> to get a list of valid configuration parameters.<n>OPTIONS<n> -h, --help<n> Print this help message and exit.<n> --debug-mode<n> Enable the debugging mode. The image will not quit on unexpected errors. This configuration can be used in the application to improve the debugging experience.<n> --settings-file=%<filename><n> Provide application configuration via a settings file. This option can occur several times to configure more than one settings file. Supported file settings formats are INI and JSON.<n> --enable-structured-logging<n> Enable structured logging. When enabled the log will be emitted in JSON format.<n><t><t>--dry-run<n><t><t><t>Perform a dry run of the application. All the configuration will be loaded (and validated), but the application will not perform any changes.<n>' ])
'NAME<n> launchpad-start - Start the selected application<n>SYNOPSYS<n> launchpad start [--help|-h] [--debug-mode] [--settings-file=%<filename>] [--enable-structured-logging] [--dry-run] %<app> [%<parameters>]<n>DESCRIPTION<n> Start the application selected via %<app>.<n><n><t><t>Application configuration is made by the command-line via %<parameters>, using environment variables or settings files.<n><n><t><t>Execute launchpad explain %<app> to get a list of valid configuration parameters.<n>OPTIONS<n> -h, --help<n> Print this help message and exit.<n> --debug-mode<n> Enable the debugging mode. The image will not quit on unexpected errors. This configuration can be used in the application to improve the debugging experience.<n> --settings-file=%<filename><n> Provide application configuration via a settings file. This option can occur several times to configure more than one settings file. Supported file settings formats are INI and JSON.<n> --enable-structured-logging<n> Enable structured logging. When enabled the log will be emitted in JSON format.<n><t><t>--dry-run<n><t><t><t>Perform a dry run of the application. All the configuration will be loaded (and validated), but the application will not start.<n>' ])
expandMacros
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : 'LaunchpadProcessingContext',
#name : 'LaunchpadApplicationContext',
#superclass : 'Object',
#instVars : [
'commandLine',
Expand All @@ -10,70 +10,70 @@ Class {
}

{ #category : 'instance creation' }
LaunchpadProcessingContext class >> handling: aCommandLine [
LaunchpadApplicationContext class >> handling: aCommandLine [

^ self handling: aCommandLine writingTo: String new writeStream
]

{ #category : 'instance creation' }
LaunchpadProcessingContext class >> handling: aCommandLine writingTo: outputStream [
LaunchpadApplicationContext class >> handling: aCommandLine writingTo: outputStream [

^ self new initializeHandling: aCommandLine writingTo: outputStream
]

{ #category : 'testing' }
LaunchpadProcessingContext class >> isAbstract [
LaunchpadApplicationContext class >> isAbstract [

<ignoreForCoverage>
^ self = LaunchpadProcessingContext
^ self = LaunchpadApplicationContext
]

{ #category : 'converting' }
LaunchpadProcessingContext >> asDryRunContext [
LaunchpadApplicationContext >> asDryRunContext [

^ self subclassResponsibility
]

{ #category : 'accessing' }
LaunchpadProcessingContext >> commandLine [
LaunchpadApplicationContext >> commandLine [

^ commandLine
]

{ #category : 'accessing' }
LaunchpadProcessingContext >> configurationProviderChainedWith: aConfigurationProvider [
LaunchpadApplicationContext >> configurationProviderChainedWith: aConfigurationProvider [

^ ConfigurationFromCommandLineProvider over: commandLine chainedWith: aConfigurationProvider
]

{ #category : 'utilities' }
LaunchpadProcessingContext >> emitErrorAndExit: message [
LaunchpadApplicationContext >> emitErrorAndExit: message [

LogRecord emitError: message.
self exitFailure
]

{ #category : 'utilities' }
LaunchpadProcessingContext >> exitFailure [
LaunchpadApplicationContext >> exitFailure [

Exit signalFailure
]

{ #category : 'utilities' }
LaunchpadProcessingContext >> exitSuccess [
LaunchpadApplicationContext >> exitSuccess [

Exit signalSuccess
]

{ #category : 'initialize' }
LaunchpadProcessingContext >> initializeHandling: aCommandLine writingTo: outputStream [
LaunchpadApplicationContext >> initializeHandling: aCommandLine writingTo: outputStream [

commandLine := aCommandLine.
output := ZnNewLineWriterStream on: outputStream
]

{ #category : 'accessing' }
LaunchpadProcessingContext >> nextCommandLineArgumentIfNone: aFailBlock [
LaunchpadApplicationContext >> nextCommandLineArgumentIfNone: aFailBlock [

commandLine withFirstArgument: [ :argument |
commandLine := commandLine copySubcommand.
Expand All @@ -83,19 +83,19 @@ LaunchpadProcessingContext >> nextCommandLineArgumentIfNone: aFailBlock [
]

{ #category : 'enumerating' }
LaunchpadProcessingContext >> outputStreamDo: aBlock [
LaunchpadApplicationContext >> outputStreamDo: aBlock [

aBlock value: output
]

{ #category : 'running' }
LaunchpadProcessingContext >> run: startupBlock [
LaunchpadApplicationContext >> run: startupBlock [

^ self subclassResponsibility
]

{ #category : 'configuration' }
LaunchpadProcessingContext >> usePlatformLineEnding [
LaunchpadApplicationContext >> usePlatformLineEnding [

output forPlatformLineEnding
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Class {
#name : 'LaunchpadApplicationDryRunContext',
#superclass : 'LaunchpadApplicationContext',
#category : 'Launchpad-Commands',
#package : 'Launchpad-Commands'
}

{ #category : 'converting' }
LaunchpadApplicationDryRunContext >> asDryRunContext [

^ self
]

{ #category : 'running' }
LaunchpadApplicationDryRunContext >> run: startupBlock [

self exitSuccess
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Class {
#name : 'LaunchpadApplicationStartingContext',
#superclass : 'LaunchpadApplicationContext',
#category : 'Launchpad-Commands',
#package : 'Launchpad-Commands'
}

{ #category : 'converting' }
LaunchpadApplicationStartingContext >> asDryRunContext [

^ LaunchpadApplicationDryRunContext handling: commandLine writingTo: output
]

{ #category : 'running' }
LaunchpadApplicationStartingContext >> run: startUpBlock [

startUpBlock value
]
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ LaunchpadCommandLineHandler class >> commandName [
{ #category : 'instance creation' }
LaunchpadCommandLineHandler class >> defaultContextForCommandLine: commandLine [

^ (LaunchpadCommandLineProcessingContext
^ (LaunchpadApplicationStartingContext
handling: commandLine
writingTo: Stdio stdout)
usePlatformLineEnding;
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion source/Launchpad-Commands/LaunchpadDryRunOption.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ LaunchpadDryRunOption >> name [
{ #category : 'accessing' }
LaunchpadDryRunOption >> summary [

^ 'Perform a dry run of the application. All the configuration will be loaded (and validated), but the application will not perform any changes.'
^ 'Perform a dry run of the application. All the configuration will be loaded (and validated), but the application will not start.'
]

This file was deleted.

0 comments on commit ecdc1b4

Please sign in to comment.