Skip to content

Commit

Permalink
CloseProject simplified and enhanced: processes now unqualified names…
Browse files Browse the repository at this point in the history
…pace names as well
  • Loading branch information
aplteam committed Dec 28, 2024
1 parent 3f4e896 commit ea0a662
Show file tree
Hide file tree
Showing 17 changed files with 169 additions and 47 deletions.
10 changes: 1 addition & 9 deletions APLSource/.linkconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
{
LinkVersion: { ID: "4.0.20"},
Settings:
{
fastLoad: 1,
forceFilenames: 1,
watch: "both",
},
}
{ LinkVersion: { ID: "4.0.20"}, Settings: { fastLoad: 1, forceFilenames: 1, watch: "both", },}
Expand Down
28 changes: 11 additions & 17 deletions APLSource/Cider/CloseProject.aplf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
r{x}CloseProject projects;list;project;ind;res;list;checks;closed
Breaks the Link between a project and its folder on disk, and potentially execute a check functon afterwards.
In case ⍵ is empty ALL projects are closed.
r{performChecks}CloseProject projects;list;project;ind;res;list;closed;buff
Breaks the Link between a project and its folder on disk, and potentially executes a check functon afterwards.
In case ⍵ is empty, ALL projects are closed.
`projects` may be one of:
1. Empty vector (=close all)
2. One or more project names like `#.Foo`
Expand All @@ -12,19 +12,8 @@
A 0 as left argument would therefore prevent checks from being performed.
Returns the number of projects closed.
r0
checks1
:If 0=⎕NC'x'
listListOpenProjects 1
:Else
:If 3=|x
(list checks){[{' '=10}¨]}x
:ElseIf ' '=10x
listx
:Else
checksx
listListOpenProjects 1
:EndIf
:EndIf
performChecks{0<⎕NC : 1}'performChecks'
listListOpenProjects 1
:If 0<list
:If 0=projects
res{⎕SE.Link.Break }¨list
Expand All @@ -35,6 +24,11 @@
projectsprojects
:For project :In projects
projectproject
:If (/~'/\'project)~(1project)'#⎕'
buff(({(-+/\~''=¨)}⎕NSI),'.'),project
('Could not identify: ',project)Assert 9=⎕NC buff
projectbuff
:EndIf
:If /'[]'project
indlist[;4]⎕C project~'[]'
:Else
Expand All @@ -49,7 +43,7 @@
closed,list[ind;2]
:EndIf
:EndFor
:If checks
:If performChecks
{}CheckForDropboxConflicts¨closed
:EndIf
:EndIf
Expand Down
10 changes: 7 additions & 3 deletions APLSource/Cider/History.apla
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
(
'* 0.46.0 ⋄ 2024-12-25'
'* 0.46.0 ⋄ 2024-12-28'
' * When a project is opened and a file .linkconfig is found in the project''s source folder, its content is'
' now checked. If it contains nothing but stop & trace vectors and Link''s version number, then that file'
' is now ignored, and any Link-related settings in Cider''s project config file are evaluated.'
' * New command ]Cider.LinkConfig added that allows printing, editing and deleting a Link config file'
' * A Cider project config file does not have to have a LINK section anymore because there might be a Link'
' configuration file be used instead. '
' configuration file be used instead.'
' * `CloseProject`: minor syntax change insofar as no project list can be provided anymore via the left argument'
' Almost certainly used only by the ]CloseProject user command'
' * `CloseProject` now processes the name of an unqualified namespace name by trying to find it in the namespace'
' it was called from.'
' * Bug fixes'
' * `]ListTatinDependencies` did not always report the folder that was investigated (#93)'
' * `]ListTatinDependencies` had a problem with -full: only obe level of sub-folders was investigated (#94)'
' * `ReadProjectConfigFile` now injects `dependencies` into the config file when undefined.'
' * The `TatinVars` namespace was created as a ref pointing to another namespace `TatinVars` which was'
' then deleted. That can cause confusion. Now the namespace is copied.'
' * `ListTatinDependencies` crashed under rare circumstances '
' * `ListTatinDependencies` crashed under rare circumstances '
'* 0.45.0 ⋄ 2024-12-09'
' * If the Dropbox check is not configured in the Cider config file, Cider now checks whether there is'
' a folder Dropbox/ in the current users home folder. If so, the check is performed.'
Expand Down
10 changes: 8 additions & 2 deletions APLSource/Cider/UC/CloseProject.aplf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rCloseProject Args;list;bool;row;invalid;noop;report;projectID;ind;noOf;fast
rCloseProject Args;list;bool;row;invalid;noop;report;projectID;ind;noOf;fast;b;buff;b2
r''
report1
fastArgs.Switch'fast'
Expand Down Expand Up @@ -29,6 +29,12 @@
((projectID=',')/projectID)' '
projectID' '()projectID
projectIDTranslateAlias¨projectID
:If /b{(/~'/\')~(1)'#⎕'}¨projectID
buff(((2++/\''=¨1⎕NSI)⎕NSI),'.'),¨b/projectID
:AndIf /b29=⎕NC¨buff
('Could not identify: ',{,',',}/b2/projectID)Assert/b2
(b/projectID)buff
:EndIf
:If 0invalid(~/¨'/\'¨projectID)~({1 ⎕C ¯1+'.'}¨projectID),¨'#' '⎕SE'
(invalid/projectID)('#.'),¨invalid/projectID
:EndIf
Expand All @@ -40,7 +46,7 @@
:If 1invalid
('Not an open Cider project: ',{,',',}/invalid/projectID)Assert/~invalid
:EndIf
r+/((~fast)list)P.CloseProject¨projectID
r+/(~fast)P.CloseProject¨projectID
:EndIf
:If 0<r
:If ' '=10r
Expand Down
5 changes: 4 additions & 1 deletion APLSource/Cider/UC/CreateProject_.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@
:If success
:If namespace
projectFolder1⎕NPARTS filename
:If '.'namespace
config.CIDER.parent{-1++/\'.'}namespace
:EndIf
:If 0=(config.CIDER.parent).⎕NC config.CIDER.projectSpace
config.CIDER.projectSpace(config.CIDER.parent).⎕NS''
:Else
:If 0<((config.CIDER.parent)config.CIDER.projectSpace).⎕NL 9~16
:If 0<(' '~¨((config.CIDER.parent)config.CIDER.projectSpace).⎕NL 9~16)~'CiderConfig'
:If 1<listP.##.F.Dir projectFolder
:OrIf P.##.ConfigFilename{1:0 ,/1⎕NPARTS}list
:If batch
Expand Down
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_OpenAndClose_001.aplf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RTest_OpenAndClose_001(stopFlag batchFlag);⎕TRAP;tempDir;list;sourceFolder1;projectFolder1;projectFolder2;sourceFolder2;aliase;rc;res;buff;msg;ref
Opens two (new) projects and then close both of them, one by alias and one by path. Uses `DropAlias`.
Opens two (new) projects and then closes both of them, one by alias and one by path. Uses `DropAlias`.
⎕TRAP(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
RT._Failed

Expand Down
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_OpenAndClose_002.aplf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RTest_OpenAndClose_002(stopFlag batchFlag);⎕TRAP;tempDir;sourceFolder;list;rc;ref;res;msg
Create and open a project and then close it by path
Creates and opens a project and then closes it by path
⎕TRAP(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
RT._Failed

Expand Down
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_OpenAndClose_004.aplf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RTest_OpenAndClose_004(stopFlag batchFlag);⎕TRAP;tempDir;list;sourceFolder1;projectFolder1;projectFolder2;sourceFolder2;aliase;rc;res;buff;msg;projectFolder3;sourceFolder3;ref
Opens three (new) projects and then close both of them in one go, one by alias and one by path. Uses `DropAlias`.
Opens 3 (new) projects and then closes 2 of them, 1 by alias and 1 by path. Uses `DropAlias`.
⎕TRAP(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
RT._Failed

Expand Down
32 changes: 32 additions & 0 deletions APLSource/TestCases/Test_OpenAndClose_005.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
RTest_OpenAndClose_005(stopFlag batchFlag);⎕TRAP;tempDir;list;sourceFolder1;projectFolder1;rc;res;buff;msg;ref
Opens a (new) project and then closes it with a namespace name that is not fully qualified
⎕TRAP(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
RT._Failed

tempDir∆GetFolderInTempDir⎕SI
projectFolder1tempDir,'/Foo'
sourceFolder1projectFolder1,'/APLSource'
'Create!'FilesAndDirs.CheckPath sourceFolder1
(projectFolder1,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Foo')
#.⎕EX'TEMP' 'TEMP.Foo'#.⎕NS''
ref∆GetRefToCommTools
ref.YesOrNo_Answers1 2'ChangeCurrentDir@' 'n'
(rc msg buff)∆UCMD'CreateProject "',projectFolder1,'" #.TEMP.Foo -noEdit -acceptConfig -batch -ignoreUserExec'
Assert rc=0
#.TEMP.Foo.⎕FX'r←Hello' 'r←''World'''
{}⎕SE.Link.Add'#.TEMP.Foo.Hello'
listFilesAndDirs.ListFiles projectFolder1
T.GoToTidyUp 1list
T.GoToTidyUp ##.Cider.ConfigFilename,/1⎕NPARTS 1list

T.GoToTidyUp 10 ##.Cider.CloseProject #.TEMP.{ ⍺⍺ }'Foo' The dfn makes sure that the namespace is correctly qualified

RT._OK

∆TidyUp:
ref.Cleanup
∆LINK'Break' '#.TEMP.Foo' We DO NOT check here because when everything is working fine...
rcFilesAndDirs.RmDir tempDir,'/..'
Assert 0=+/rc
#.⎕EX'TEMP'
Done
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
rTest_UC_001(stopFlag batchFlag);⎕TRAP;tempDir;parms;list;rc;msg;result;res;log;ref
rTest_UC_300(stopFlag batchFlag);⎕TRAP;tempDir;parms;list;rc;msg;result;res;log;ref
Exercise the user command on "CloseProject" on a project that was loaded into a non-default "parent"
Should work anyway if there is just one project with that name
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')
rT._Failed

#.⎕EX'Goo' 'Goo'#.⎕NS''
#.⎕EX'Foo' 'Foo'#.⎕NS''
tempDir∆GetFolderInTempDir⎕SI
(tempDir,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Foo')
3 ⎕MKDIR tempDir,'/APLSource'
Expand All @@ -19,15 +19,15 @@
parms##.Cider.CreateOpenParms
parms.foldertempDir
parms.watch'ns'
parms.parent'#.Goo'
parms.parent'#.Foo'
parms.ignoreUserExec1
parms.batch1
##.Cider.C.YesOrNo_Answers1 2'ChangeCurrentDir@' 'n'
(res log)##.Cider.OpenProject parms

T.GoToTidyUp 0=list##.Cider.ListOpenProjects 0

(rc msg result)∆UCMD'CloseProject #.Goo.Foo -fast'
(rc msg result)∆UCMD'CloseProject #.Foo.Foo -fast'
msg Assert rc=0
T.GoToTidyUp'Number of projects closed: 1'result

Expand All @@ -36,8 +36,8 @@
∆TidyUp:
ref.Cleanup
##.Cider.C.Cleanup
∆LINK'Break' '#.Foo.Goo' We DO NOT check here because when everything is working fine then it's not linked anymore.
∆LINK'Break' '#.Foo.Foo' We DO NOT check here because when everything is working fine then it's not linked anymore.
rcFilesAndDirs.RmDir tempDir,'/..'
Assert 0=+/rc
#.⎕EX'Goo'
#.⎕EX'Foo'
Done
42 changes: 42 additions & 0 deletions APLSource/TestCases/Test_UC_301.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
rTest_UC_301(stopFlag batchFlag);⎕TRAP;tempDir;parms;list;rc;msg;res;log;ref;noOf
Exercise the user command on "CloseProject" with a non-qualified namespace name called from #
Should work anyway if there is just one project with that name
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')
rT._Failed

#.⎕EX'Foo' 'Foo'#.⎕NS''
tempDir∆GetFolderInTempDir⎕SI
(tempDir,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Foo')
3 ⎕MKDIR tempDir,'/APLSource'

ref∆GetRefToCommTools
ref.YesOrNo_Answers1 2'ChangeCurrentDir@' 'n'
(rc msg res)∆UCMD'CreateProject "',tempDir,'" -noEdit -acceptConfig -batch -ignoreUserExec'
Assert rc=0
(rc msg res)∆UCMD'CloseProject #.Foo -fast'
Assert rc=0

parms##.Cider.CreateOpenParms
parms.foldertempDir
parms.watch'ns'
parms.parent'#.Foo'
parms.ignoreUserExec1
parms.batch1
##.Cider.C.YesOrNo_Answers1 2'ChangeCurrentDir@' 'n'
(res log)##.Cider.OpenProject parms

T.GoToTidyUp 0=list##.Cider.ListOpenProjects 0

noOf⎕SE.UCMD #.{⍺⍺ }'Cider.CloseProject Foo.Foo -fast' We MUST NOT use ∆UCMD here, otherwise we cannot establoish where CloseProject was called from
T.GoToTidyUp'Number of projects closed: 1'noOf

rT._OK

∆TidyUp:
ref.Cleanup
##.Cider.C.Cleanup
∆LINK'Break' '#.Foo.Foo' We DO NOT check here because when everything is working fine then it's not linked anymore.
rcFilesAndDirs.RmDir tempDir,'/..'
Assert 0=+/rc
#.⎕EX'Foo'
Done
42 changes: 42 additions & 0 deletions APLSource/TestCases/Test_UC_302.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
rTest_UC_302(stopFlag batchFlag);⎕TRAP;tempDir;parms;list;rc;msg;res;log;ref;noOf
Exercise the user command on "CloseProject" with a non-qualified namespace name, called from #.Foo
Should work anyway if there is just one project with that name
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')
rT._Failed

#.⎕EX'Foo' 'Foo'#.⎕NS''
tempDir∆GetFolderInTempDir⎕SI
(tempDir,'/cider.config')⎕NCOPY(##.CiderConfig.HOME,'/TestData/cider.config.Foo')
3 ⎕MKDIR tempDir,'/APLSource'

ref∆GetRefToCommTools
ref.YesOrNo_Answers1 2'ChangeCurrentDir@' 'n'
(rc msg res)∆UCMD'CreateProject "',tempDir,'" -noEdit -acceptConfig -batch -ignoreUserExec'
Assert rc=0
(rc msg res)∆UCMD'CloseProject #.Foo -fast'
Assert rc=0

parms##.Cider.CreateOpenParms
parms.foldertempDir
parms.watch'ns'
parms.parent'#.Foo'
parms.ignoreUserExec1
parms.batch1
##.Cider.C.YesOrNo_Answers1 2'ChangeCurrentDir@' 'n'
(res log)##.Cider.OpenProject parms

T.GoToTidyUp 0=list##.Cider.ListOpenProjects 0

noOf⎕SE.UCMD #.Foo.{⍺⍺ }'Cider.CloseProject Foo -fast' We MUST NOT use ∆UCMD here, otherwise we cannot establoish where CloseProject was called from
T.GoToTidyUp'Number of projects closed: 1'noOf

rT._OK

∆TidyUp:
ref.Cleanup
##.Cider.C.Cleanup
∆LINK'Break' '#.Foo.Foo' We DO NOT check here because when everything is working fine then it's not linked anymore.
rcFilesAndDirs.RmDir tempDir,'/..'
Assert 0=+/rc
#.⎕EX'Foo'
Done
2 changes: 1 addition & 1 deletion apl-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
tags: "project-management",
tatin_version: "0.103.0",
userCommandScript: "APLSource/Cider_UC.dyalog",
version: "0.46.0-beta-19+867",
version: "0.46.0-beta-20+868",
}
6 changes: 6 additions & 0 deletions cider.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
tatinVars: "Cider",
tests: "TestCases.RunTests",
},
LINK: {
// These are LINK parameters which are passed on to LINK when Cider brings the APL code into the WS with LINK.
// With Link 4.0 there is no need any more to use this because Link has now its own config file.
// Until Link 4.0.0 is the only Link version supported, we allow non-default settings to be defined here.
// Note that from version 0.46.0 onwards, this section is optional, not mandatory anymore.
},
SYSVARS: {
io: 1,
ml: 1,
Expand Down
3 changes: 2 additions & 1 deletion docs/Cider-API-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ Defaults to 0, meaning that Cider will load Tatin packages by honoring the confi
Defaults to 0, meaning that the function prints messages to the session. If this is 1 then no messages are printed but what would have been printed is still returned as second element of the result of the function.


#### suppressLX
#### suppressInit

Defaults to 0, meaning that the projects initialisation function (if any) will be executed.

Expand Down Expand Up @@ -565,5 +565,6 @@ This can be just `1.2.3`, but it may be something like `1.2.3-beta-1+113`






Loading

0 comments on commit ea0a662

Please sign in to comment.