Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with CLAP functional #440

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Pillar-Chrysal/ConfigurationForPillar.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Now to exist and be used I do not need the full Chrysal package, just the runtim
Class {
#name : #ConfigurationForPillar,
#superclass : #ChrysalPillarishConfiguration,
#category : 'Pillar-Chrysal'
#category : #'Pillar-Chrysal'
}

{ #category : #description }
Expand Down Expand Up @@ -175,7 +175,7 @@ ConfigurationForPillar >> attribution: aValue [
{ #category : #accessing }
ConfigurationForPillar >> baseDirectory [
"generated code"
^ self propertyAt: #baseDirectory ifAbsent: [(FileSystem workingDirectory / '.')]
^ (FileSystem workingDirectory)
]

{ #category : #accessing }
Expand Down
24 changes: 24 additions & 0 deletions src/Pillar-Cli/ClapPillarBuildCommand.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Class {
#name : #ClapPillarBuildCommand,
#superclass : #ClapApplication,
#category : #'Pillar-Cli-Clap'
}

{ #category : #'command line' }
ClapPillarBuildCommand class >> commandSpecification [
<commandline>

| command |

command := (ClapCommand id: #build)
description: 'Build your Pillar documents and export with a given format';
add: ClapFlag forHelp;
yourself.

PRTarget clapCommandList do: [ :each |
command addSubcommand: each
].
^ command meaning: [ :args |
args at: #helpFlag ifPresent: [ :help | help value; exitSuccess ].
]
]
85 changes: 71 additions & 14 deletions src/Pillar-ExporterCore/PRTarget.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,46 @@ Class {
#category : #'Pillar-ExporterCore-Base'
}

{ #category : #clap }
PRTarget class >> buildClapCommand [

| target project |
target := self new.
project := self newProject.

^ (ClapCommand id: self clapId)
description: 'Build your Pillar documents in ', self clapId ,' format';
add: ClapFlag forHelp;
add: ((ClapFlag id: #templatable)
description: 'Use a template');
meaning: [project beTemplatable];
add: ((ClapFlag id: #all)
description: 'Build all Pillar documents in repository';
canonicalName: 'a';
meaning: [ PRBuildAllStrategy new ]);
add: ((ClapFlag id: #mainRoot)
description: 'Build index.pillar in root directory';
canonicalName: 'm';
meaning: [ PRBuildRootMainStrategy new ]);
add: ((ClapPositional id: #requestedFiles)
description: 'Pillar files you want to build';
multiple: true;
meaning: [ :doc | doc word asFileReference ]);
meaning: [ :args |
args at: #helpFlag ifPresent: [ :help | help value; exitSuccess ].
args at: #templatable ifPresent: [(args at: #templatable) value ].
"here, default strategy is mainRoot and the following order give strategies a priority order"
(args at: #requestedFiles ) isExplicit ifTrue:[
target buildStrategy: (PRBuildListStrategy list: (args occurrencesOf: #requestedFiles collect: #value) )
].
args at: #all ifPresent: [ :strat | target buildStrategy: strat value ].
args at: #mainRoot ifPresent: [ :strat | target buildStrategy: strat value].

cdlm marked this conversation as resolved.
Show resolved Hide resolved
target buildWithClapArguments: project ]

yourself
]

{ #category : #accessing }
PRTarget class >> builderClassForName: aString [

Expand All @@ -31,28 +71,34 @@ PRTarget class >> builderName [
^ self subclassResponsibility
]

{ #category : #testing }
PRTarget class >> isAbstract [
^ self == PRTarget
{ #category : #clap }
PRTarget class >> clapCommandList [
^ self allSubclasses
select: [ :each | each isAbstract not ]
thenCollect: [ :each | each buildClapCommand ]
]

{ #category : #accessing }
PRTarget >> addPillarDocumentTransformation: aTransformation [
{ #category : #clap }
PRTarget class >> clapId [

transformations add: aTransformation
^ self builderName
]

{ #category : #building }
PRTarget >> buildAll [
{ #category : #testing }
PRTarget class >> isAbstract [
^ self == PRTarget
]

{ #category : #'clap-integration' }
PRTarget class >> newProject [

buildStrategy := PRBuildAllStrategy new
^ PRProject on: FileSystem workingDirectory
]

{ #category : #building }
PRTarget >> buildMainRoot [
"To compile only the pillar file that can be found on the top-level."
{ #category : #accessing }
PRTarget >> addPillarDocumentTransformation: aTransformation [

buildStrategy := PRBuildRootMainStrategy new
transformations add: aTransformation
]

{ #category : #building }
Expand All @@ -77,6 +123,17 @@ PRTarget >> buildOnly: aListOfFileReferences [
buildStrategy := PRBuildListStrategy list: aListOfFileReferences
]

{ #category : #accessing }
PRTarget >> buildStrategy: aStrategy [
buildStrategy := aStrategy
]

{ #category : #'clap-integration' }
PRTarget >> buildWithClapArguments: project [

(project build: self) exitProcess
]

{ #category : #building }
PRTarget >> documentFor: aFile [

Expand All @@ -94,7 +151,7 @@ PRTarget >> initialize [
super initialize.
transformations := Set new.
"self buildAll"
self buildMainRoot
buildStrategy := PRBuildRootMainStrategy new.
]

{ #category : #preparation }
Expand Down