Skip to content

Commit 7df5ceb

Browse files
committed
Bug fix and -quite for CreateProject
1 parent 2433575 commit 7df5ceb

17 files changed

+156
-59
lines changed

APLSource/Cider.aplc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@
77

88
∇ r←Version
99
:Access Public Shared
10-
r←'Cider' '0.8.5+181' '2022-03-14'
10+
r←'Cider' '0.9.0+193' '2022-03-17'
11+
⍝ * The alias syntax got enhanced; accepts now a wildcard like ]Cider.OpenProject [co*]
12+
⍝ * ]Cider.CreateProject now asks the user whether the project should also be opened.
13+
⍝ It did so in the past but silently, leaving some room for doubt.
14+
⍝ * Mainly for tests the ]Cider.CreateProject command now has a -quiet flag.
15+
⍝ * When no namespace is passed to ]Cider.CreateProject the last part of the path is taken as name
1116
⍝ * The file cider.config.RemoveMe got renamed to cider.config.template
1217
⍝ * When a tatin installation folder does not exist or is empty no error is generated anymore
1318
⍝ * Bug fixes:
1419
⍝ * Alias names should NOT be case-sensitive.
20+
⍝ * Some user commands accepted an argument when they shouldn't.
21+
⍝ * Erratic RANK ERROR on OpenProject fixed
1522
⍝ * 0.8.4+176 ⋄ 2022-02-27
1623
⍝ * Minor internal improvements
1724
⍝ * LF is now enforced for text files via .gitattributes
@@ -137,6 +144,7 @@
137144
:Else
138145
projectSpace_←⍎parms.projectSpace(⍎parms.parent).⎕NS'' ⍝ Create project space from "parent" to avoid problems
139146
:EndIf
147+
'Already opened?!'Assert~CheckForAlreadyOpened projectSpace_
140148
CheckParameters config
141149
configFilename HandleSysVars config
142150
source←parms.folder,(0<≢config.CIDER.source)/'/',config.CIDER.source ⍝ For linking we are only interested in the code folder
@@ -884,4 +892,13 @@
884892
:EndIf
885893
886894

895+
∇ flag←CheckForAlreadyOpened projectSpace;activeLinks
896+
⍝ Returns a 1 in case projectSpace is already opened, otherwise 0
897+
flag←0
898+
:If 2=⍴⍴activeLinks←⎕SE.Link.Status''
899+
:AndIf 0<≢activeLinks ⍝ Maybe one day when Link has a real API...
900+
flag←(⊂⍕projectSpace)∊activeLinks[;1]
901+
:EndIf
902+
903+
887904
:EndClass

APLSource/Cider_uc.dyalog

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:Class Cider_uc
22
User Command class for the project manager "Cider"
3-
Kai Jaeger ⋄ APL Team Ltd
3+
Kai Jaeger
44

55
⎕IO1 ⎕ML1 ⎕WX3
66
MinimumVersionOfDyalog'18.0'
@@ -18,7 +18,7 @@
1818
c.Group'Cider'
1919
c.Parse'1s -projectSpace= -parent= -alias= -suppressLX -quiet -import -noPkgLoad -watch=ns dir both'
2020
r,c
21-
21+
2222
c⎕NS''
2323
c.Name'ListOpenProjects'
2424
c.Desc'List all currently open projects'
@@ -37,7 +37,7 @@
3737
c.Name'CreateProject'
3838
c.Desc'Makes the given folder a project folder'
3939
c.Group'Cider'
40-
c.Parse'2s -alias= -acceptConfig -noEdit'
40+
c.Parse'2s -alias= -acceptConfig -noEdit -quiet'
4141
r,c
4242

4343
c⎕NS''
@@ -133,9 +133,9 @@
133133
:EndIf
134134
:If 0=Args._2
135135
:OrIf 0Args._2
136-
rCreateProject_ folder(Args.acceptConfig)(Args.noEdit)
136+
rCreateProject_ folder(Args.acceptConfig)(Args.noEdit)(Args.quiet)
137137
:Else
138-
rArgs._2 CreateProject_ folder(Args.acceptConfig)(Args.noEdit)
138+
rArgs._2 CreateProject_ folder(Args.acceptConfig)(Args.noEdit)(Args.quiet)
139139
:EndIf
140140
:If 0Args.alias
141141
:If 0<msgP.ProcessAlias folder Args.alias
@@ -158,7 +158,7 @@
158158
r(AddTitles)'Namespace name' 'Path',Args.verbose/'No. of objects' 'Alias'
159159
160160

161-
rOpenProject Args;path;parms
161+
rOpenProject Args;path;parms;aliasDefs;bool;info;opCode;alias
162162
r0 0''
163163
Args.projectSpace{(,0),:'' }Args.projectSpace
164164
:If 0Args._1
@@ -180,10 +180,28 @@
180180
:Else
181181
pathArgs._1
182182
:EndIf
183+
aliasDefsP.GetAliasFileContent
183184
:If (,path),¨'[' '[?' '[?]'
184-
:If 0=pathSelectFromAliases
185+
:If 0=pathSelectFromAliases aliasDefs
185186
:Return
186187
:EndIf
188+
:ElseIf '['=1path
189+
:AndIf '*'=¯1path~'[]'
190+
bool(¯1path~'[]'){(⎕C()[2]).=⎕C }aliasDefs[;1]
191+
:Select +/bool
192+
:Case 0
193+
:Return
194+
:Case 1
195+
(alias path)aliasDefs[bool1;]
196+
:If 0=1 YesOrNo'Sure you want to open "',path,'" ?'
197+
:Return
198+
:EndIf
199+
:Else
200+
info'(',((+/bool),' of ',(aliasDefs)),')'
201+
:If 0=pathinfo SelectFromAliases boolaliasDefs
202+
:Return
203+
:EndIf
204+
:EndSelect
187205
:EndIf
188206
path⎕C('['path)path
189207
parmsP.CreateOpenParms''
@@ -218,7 +236,7 @@
218236
r,']Cider.ListAliases [-prune] [-edit] [-quiet]'
219237
:Case ⎕C'CreateProject'
220238
r,'Makes the given folder a project folder'
221-
r,']Cider.CreateProject <folder> [<project-namespace>] [-alias=] [-acceptConfig] [-noEdit]'
239+
r,']Cider.CreateProject <folder> [<project-namespace>] [-alias=] [-acceptConfig] [-noEdit] [-quiet]'
222240
:Case ⎕C'CloseProject'
223241
r,'Breaks the Link between the project space and the files on disk'
224242
r,']Cider.CloseProject [<project-namespace>] [-all]'
@@ -300,6 +318,7 @@
300318
r,' * Lets the user edit that file and makes sure that all mandatory settings are done and'
301319
r,' also that those are correct'
302320
r,' * In case an alias is specified the alias is saved'
321+
r,' * Finally it attempts to open the new project'
303322
r,''
304323
r,'If no path is specified it acts on the current directory, but in that case the user'
305324
r,'is prompted for confirmation to avoid mishaps.'
@@ -310,6 +329,9 @@
310329
r,'-noEdit: With -noEdit you can prevent the user from being asked to edit the config file.'
311330
r,'-alias: In case you are going to work on that project frequently you may specify'
312331
r,' -alias=name'
332+
r,'-quiet After a project has been created successfully, the user will be asked whether'
333+
r,' she wants to open the project as well. You can enforce that without the user'
334+
r,' being interrogated by setting the -quiet flag. Mainly useful for test cases.'
313335
r,'Note that the alias is not case sensitive'
314336
:Case ⎕C'CloseProject'
315337
r,'Breaks the Link between the project and the files on disk.'
@@ -411,9 +433,9 @@
411433
PP,'.Cider'
412434
413435

414-
r{namespace}CreateProject_(folder acceptFlag noEditFlag);filename;success;config;projectFolder;parms
436+
r{namespace}CreateProject_(folder acceptFlag noEditFlag quietFlag);filename;success;config;projectFolder;parms
415437
:Access Public Shared
416-
namespace{0<⎕NC : ''}'namespace'
438+
namespacefolder{0<⎕NC : ¯1{/0<¨}(~'/\')}'namespace'
417439
r''
418440
:If 0folder
419441
folder1 ⎕NPARTS''
@@ -459,6 +481,7 @@
459481
parms.projectSpaceconfig.CIDER.projectSpace
460482
parms.parentconfig.CIDER.parent
461483
parms.quietFlag1
484+
:AndIf {:1 1 YesOrNo'Project successfully created; open as well?' 1}quietFlag
462485
:AndIf P.OpenProject parms
463486
r'Project created and opened'
464487
:Else
@@ -518,6 +541,7 @@
518541
:Else
519542
nameArgs._1
520543
:If ~(Args._1)'#⎕'
544+
'Not a valid APL name'Assert(⎕NS'').{0=⎕NC }name~'[]'
521545
listP.ListOpenProjects 0
522546
:If 0<list
523547
:If 1=+/boolname¨{'.'}¨list[;1]
@@ -698,10 +722,15 @@
698722
:Until isOkay
699723
700724

701-
rSelectFromAliases dummy;data;row
725+
r{caption}SelectFromAliases data;row
702726
r
703-
:If 0<dataP.GetAliasFileContent
727+
caption{0<⎕NC : ''}'caption'
728+
:If 0=data
729+
dataP.GetAliasFileContent
730+
:EndIf
731+
:If 0<data
704732
data[;1]{'[',,']'}¨data[;1]
733+
caption'Select project to be opened',({0=: ' ',,' '}caption),':'
705734
:AndIf row'Select project to be opened:'SelectOneItem⎕FMT data
706735
rrowdata[;2]
707736
:EndIf
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
R←Test_Create_001(stopFlag batchFlag);⎕TRAP;tempDir;sourceFolder;list;config
22
⍝ Create a project from a folder without Linking a namespace; project space name defaults
33
⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
4-
54
R←T._Failed
5+
66
tempDir←FilesAndDirs.GetTempSubDir⊃⎕SI
77
sourceFolder←tempDir,'/APLSource'
88
'Create!'FilesAndDirs.CheckPath sourceFolder
99
(⊂'r←Hello' 'r←''World''')FilesAndDirs.NPUT sourceFolder,'/hello.aplf'
1010

11-
{}⎕SE.UCMD'Cider.CreateProject "',tempDir,'" -noEdit'
11+
{}⎕SE.UCMD'Cider.CreateProject "',tempDir,'" -noEdit -quiet'
1212
list←FilesAndDirs.ListFiles tempDir
1313
→T.GoToTidyUp 1≠≢list
1414
→T.GoToTidyUp'cider.config'≢⊃,/1↓⎕NPARTS 1⊃list
@@ -18,5 +18,6 @@
1818
R←T._OK
1919

2020
∆TidyUp:
21+
∆LINK'Break'(#.⊃{⍺,'.',⍵}/config.CIDER.(parent projectSpace))
2122
FilesAndDirs.RmDir tempDir
2223
⍝Done

APLSource/TestCases/Test_Misc_005.aplf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
44
r←T._Failed
55

6+
:If ~batchFlag
7+
⎕←'Sorry, but this will take a while...'
8+
:EndIf
9+
610
dir←FilesAndDirs.GetTempPath,'Cider/',⊃⎕SI
711
FilesAndDirs.RmDir dir ⍝ Paranoia...
812
3 ⎕MKDIR dir
@@ -27,5 +31,5 @@
2731
r←T._OK
2832

2933
∆TidyUp:
30-
{}⎕SE.Link.Break #.TEMP
34+
∆LINK'Break'#.TEMP
3135
FilesAndDirs.RmDir dir

APLSource/TestCases/Test_OpenAndClose_001.aplf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
R←Test_OpenAndClose_001(stopFlag batchFlag);⎕TRAP;tempDir;list;sourceFolder1;projectFolder1;projectFolder2;sourceFolder2;aliase
22
⍝ Open two (new) projects and then close both of them, one by alias and one by path. Uses `DropAlias`.
33
⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
4-
54
R←T._Failed
6-
tempDir←FilesAndDirs.GetTempSubDir⊃⎕SI
75

6+
tempDir←FilesAndDirs.GetTempSubDir⊃⎕SI
87
projectFolder1←tempDir,'/Foo'
98
sourceFolder1←projectFolder1,'/APLSource'
109
'Create!'FilesAndDirs.CheckPath sourceFolder1
1110
(projectFolder1,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Foo')
1211
'Foo'#.⎕NS''
13-
{}⎕SE.UCMD'Cider.CreateProject "',projectFolder1,'" #.Foo -alias=test-case-alias-Foo -noEdit -acceptConfig'
12+
{}⎕SE.UCMD'Cider.CreateProject "',projectFolder1,'" #.Foo -alias=test-case-alias-Foo -noEdit -acceptConfig -quiet'
1413
#.Foo.⎕FX'r←Hello' 'r←''World'''
1514
{}⎕SE.Link.Add'#.Foo.Hello'
1615
list←FilesAndDirs.ListFiles projectFolder1
@@ -25,7 +24,7 @@
2524
(projectFolder2,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Goo')
2625
'Goo'#.⎕NS''
2726
#.Goo.⎕FX'r←Hello' 'r←''Galaxy'''
28-
{}⎕SE.UCMD'Cider.CreateProject "',projectFolder2,'" #.Goo -alias=test-case-alias-Goo -noEdit -acceptConfig'
27+
{}⎕SE.UCMD'Cider.CreateProject "',projectFolder2,'" #.Goo -alias=test-case-alias-Goo -noEdit -acceptConfig -quiet'
2928
list←FilesAndDirs.ListFiles projectFolder2
3029
→T.GoToTidyUp 1≠≢list
3130
→T.GoToTidyUp'cider.config'≢⊃,/1↓⎕NPARTS 1⊃list
@@ -39,8 +38,8 @@
3938
R←T._OK
4039

4140
∆TidyUp:
42-
{}⎕SE.Link.Break'#.Foo'
43-
{}⎕SE.Link.Break'#.Goo'
41+
∆LINK'Break' '#.Foo'
42+
∆LINK'Break' '#.Goo'
4443
{}FilesAndDirs.RmDir tempDir
4544
#.⎕EX¨'Foo' 'Goo'
4645
⎕SE.Cider.DropAlias'test-case-alias-Foo' 'test-case-alias-Goo'
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
R←Test_OpenAndClose_002(stopFlag batchFlag);⎕TRAP;tempDir;sourceFolder;list
2-
⍝ Open two (new) projects and then close both of them, one by alias and one by path
2+
⍝ Open a (new) project and then close it by path
33
⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
4-
54
R←T._Failed
5+
66
tempDir←FilesAndDirs.GetTempSubDir⊃⎕SI
77
sourceFolder←tempDir,'/APLSource'
88
'Create!'FilesAndDirs.CheckPath sourceFolder
99
(tempDir,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Foo')
1010
(⊂'r←Hello' 'r←''World''')FilesAndDirs.NPUT sourceFolder,'/hello.aplf'
1111

12-
{}⎕SE.UCMD'Cider.CreateProject "',tempDir,'" -noEdit -acceptConfig'
12+
{}⎕SE.UCMD'Cider.CreateProject "',tempDir,'" # -noEdit -acceptConfig -quiet'
1313
list←FilesAndDirs.ListFiles tempDir
1414
→T.GoToTidyUp 1≠≢list
1515
→T.GoToTidyUp'cider.config'≢⊃,/1↓⎕NPARTS 1⊃list
1616

1717
R←T._OK
1818

1919
∆TidyUp:
20+
∆LINK'Break' '#.Foo'
2021
FilesAndDirs.RmDir tempDir
2122
⍝Done
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
R←Test_OpenAndClose_003(stopFlag batchFlag);⎕TRAP;tempDir;list;res;parms
1+
R←Test_OpenAndClose_003(stopFlag batchFlag);⎕TRAP;tempDir;list;res
22
⍝ Open a (new) project and then attempt to close a non-existing one (was once a bug)
33
⍝ The bug: closed ALL projects rather than none
44
⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
5-
65
R←T._Failed
6+
77
tempDir←FilesAndDirs.GetTempSubDir⊃⎕SI
88
(tempDir,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Foo')
99

10-
{}⎕SE.UCMD'Cider.CreateProject "',tempDir,'" -noEdit -acceptConfig'
11-
12-
parms←##.Cider.CreateOpenParms ⍬
13-
parms.folder←tempDir
14-
parms.quietFlag←1
15-
res←##.Cider.OpenProject parms
10+
{}⎕SE.UCMD'Cider.CreateProject "',tempDir,'" -noEdit -acceptConfig -quiet'
1611

1712
list←##.Cider.ListOpenProjects 0
1813
→T.GoToTidyUp 0≠##.Cider.CloseProject'DoesNotExist'
@@ -23,6 +18,7 @@
2318
R←T._OK
2419

2520
∆TidyUp:
21+
res←∆LINK'Break' 'Foo'
2622
FilesAndDirs.RmDir tempDir
2723
#.⎕EX'Foo'
2824
⍝Done

APLSource/TestCases/Test_Open_005.aplf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
R←Test_Open_005(stopFlag batchFlag);⎕TRAP;parms;folder;r;res
1+
R←Test_Open_005(stopFlag batchFlag);⎕TRAP;parms;folder;r
22
⍝ Open a project with an initialisation function
33
⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
44
R←T._Failed
@@ -19,7 +19,6 @@
1919
R←T._OK
2020

2121
∆TidyUp:
22-
res←⎕SE.Link.Break'#.TEMP.Foo'
23-
Assert res ∆StartsWith'Unlinked:'
22+
∆LINK'Break' '#.TEMP.Foo'
2423
#.⎕EX'TEMP'
2524
⍝Done

APLSource/TestCases/Test_Open_007.aplf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
R←Test_Open_007(stopFlag batchFlag);⎕TRAP;parms;folder;r;res
1+
R←Test_Open_007(stopFlag batchFlag);⎕TRAP;parms;folder;r
22
⍝ Open a project with two (diamondized) initialisation functions
33
⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
44
R←T._Failed
@@ -19,7 +19,6 @@
1919
R←T._OK
2020

2121
∆TidyUp:
22-
res←⎕SE.Link.Break'#.TEMP.Foo'
23-
Assert res ∆StartsWith'Unlinked:'
22+
∆LINK 'Break' '#.TEMP.Foo'
2423
#.⎕EX'TEMP'
2524
⍝Done

APLSource/TestCases/Test_Tatin_004.aplf

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
R←Test_Tatin_004(stopFlag batchFlag);⎕TRAP;res;folder;parms;dmx
2-
⍝ Attempt to load project with a path pointing to installed Tatin packages that is non-existen.
1+
R←Test_Tatin_004(stopFlag batchFlag);⎕TRAP;res;folder;parms
2+
⍝ Attempt to load project with a path pointing to installed Tatin packages that is non-existent.
3+
⍝ Will work from 0.9.0 onwards
34
⎕TRAP←(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
45
R←T._Failed
56

@@ -10,13 +11,7 @@
1011
parms.folder←folder
1112
parms.quietFlag←1
1213

13-
:Trap 0
14-
res←##.Cider.OpenProject parms
15-
→T.GoToTidyUp 1
16-
:Else
17-
dmx←⎕DMX
18-
→T.GoToTidyUp~dmx.EM ∆StartsWith'Tatin installation folder does not exist'
19-
:EndTrap
14+
res←##.Cider.OpenProject parms
2015

2116
R←T._OK
2217

0 commit comments

Comments
 (0)