|
1 | 1 | :Class Cider_uc |
2 | 2 | ⍝ User Command class for the project manager "Cider" |
3 | | -⍝ Kai Jaeger ⋄ APL Team Ltd |
| 3 | +⍝ Kai Jaeger |
4 | 4 |
|
5 | 5 | ⎕IO←1 ⋄ ⎕ML←1 ⋄ ⎕WX←3 |
6 | 6 | MinimumVersionOfDyalog←'18.0' |
|
18 | 18 | c.Group←'Cider' |
19 | 19 | c.Parse←'1s -projectSpace= -parent= -alias= -suppressLX -quiet -import -noPkgLoad -watch=ns dir both' |
20 | 20 | r,←c |
21 | | - |
| 21 | + |
22 | 22 | c←⎕NS'' |
23 | 23 | c.Name←'ListOpenProjects' |
24 | 24 | c.Desc←'List all currently open projects' |
|
37 | 37 | c.Name←'CreateProject' |
38 | 38 | c.Desc←'Makes the given folder a project folder' |
39 | 39 | c.Group←'Cider' |
40 | | - c.Parse←'2s -alias= -acceptConfig -noEdit' |
| 40 | + c.Parse←'2s -alias= -acceptConfig -noEdit -quiet' |
41 | 41 | r,←c |
42 | 42 |
|
43 | 43 | c←⎕NS'' |
|
133 | 133 | :EndIf |
134 | 134 | :If 0=≢Args._2 |
135 | 135 | :OrIf 0≡Args._2 |
136 | | - r←CreateProject_ folder(Args.acceptConfig)(Args.noEdit) |
| 136 | + r←CreateProject_ folder(Args.acceptConfig)(Args.noEdit)(Args.quiet) |
137 | 137 | :Else |
138 | | - r←Args._2 CreateProject_ folder(Args.acceptConfig)(Args.noEdit) |
| 138 | + r←Args._2 CreateProject_ folder(Args.acceptConfig)(Args.noEdit)(Args.quiet) |
139 | 139 | :EndIf |
140 | 140 | :If 0≢Args.alias |
141 | 141 | :If 0<≢msg←P.ProcessAlias folder Args.alias |
|
158 | 158 | r(AddTitles)←'Namespace name' 'Path',Args.verbose/'No. of objects' 'Alias' |
159 | 159 | ∇ |
160 | 160 |
|
161 | | - ∇ r←OpenProject Args;path;parms |
| 161 | + ∇ r←OpenProject Args;path;parms;aliasDefs;bool;info;opCode;alias |
162 | 162 | r←0 0⍴'' |
163 | 163 | Args.projectSpace←{(,0)≡,⍵:'' ⋄ ⍵}Args.projectSpace |
164 | 164 | :If 0≡Args._1 |
|
180 | 180 | :Else |
181 | 181 | path←Args._1 |
182 | 182 | :EndIf |
| 183 | + aliasDefs←P.GetAliasFileContent |
183 | 184 | :If (⊂,path)∊,¨'[' '[?' '[?]' |
184 | | - :If 0=≢path←SelectFromAliases ⍬ |
| 185 | + :If 0=≢path←SelectFromAliases aliasDefs |
185 | 186 | :Return |
186 | 187 | :EndIf |
| 188 | + :ElseIf '['=1⍴path |
| 189 | + :AndIf '*'=¯1↑path~'[]' |
| 190 | + bool←(¯1↓path~'[]'){(⎕C(≢⍺)↑[2]⍵)∧.=⎕C ⍺}↑aliasDefs[;1] |
| 191 | + :Select +/bool |
| 192 | + :Case 0 |
| 193 | + :Return |
| 194 | + :Case 1 |
| 195 | + (alias path)←aliasDefs[bool⍳1;] |
| 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=≢path←info SelectFromAliases bool⌿aliasDefs |
| 202 | + :Return |
| 203 | + :EndIf |
| 204 | + :EndSelect |
187 | 205 | :EndIf |
188 | 206 | path←⎕C⍣('['∊path)⊣path |
189 | 207 | parms←P.CreateOpenParms'' |
|
218 | 236 | r,←⊂']Cider.ListAliases [-prune] [-edit] [-quiet]' |
219 | 237 | :Case ⎕C'CreateProject' |
220 | 238 | 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]' |
222 | 240 | :Case ⎕C'CloseProject' |
223 | 241 | r,←⊂'Breaks the Link between the project space and the files on disk' |
224 | 242 | r,←⊂']Cider.CloseProject [<project-namespace>] [-all]' |
|
300 | 318 | r,←⊂' * Lets the user edit that file and makes sure that all mandatory settings are done and' |
301 | 319 | r,←⊂' also that those are correct' |
302 | 320 | r,←⊂' * In case an alias is specified the alias is saved' |
| 321 | + r,←⊂' * Finally it attempts to open the new project' |
303 | 322 | r,←⊂'' |
304 | 323 | r,←⊂'If no path is specified it acts on the current directory, but in that case the user' |
305 | 324 | r,←⊂'is prompted for confirmation to avoid mishaps.' |
|
310 | 329 | r,←⊂'-noEdit: With -noEdit you can prevent the user from being asked to edit the config file.' |
311 | 330 | r,←⊂'-alias: In case you are going to work on that project frequently you may specify' |
312 | 331 | 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.' |
313 | 335 | r,←⊂'Note that the alias is not case sensitive' |
314 | 336 | :Case ⎕C'CloseProject' |
315 | 337 | r,←⊂'Breaks the Link between the project and the files on disk.' |
|
411 | 433 | P←⍎P,'.Cider' |
412 | 434 | ∇ |
413 | 435 |
|
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 |
415 | 437 | :Access Public Shared |
416 | | - namespace←{0<⎕NC ⍵:⍎⍵ ⋄ ''}'namespace' |
| 438 | + namespace←folder{0<⎕NC ⍵:⍎⍵ ⋄ ⊃¯1↑{⍵/⍨0<≢¨⍵}(~⍺∊'/\')⊆⍺}'namespace' |
417 | 439 | r←'' |
418 | 440 | :If 0≡folder |
419 | 441 | folder←⊃1 ⎕NPARTS'' |
|
459 | 481 | parms.projectSpace←config.CIDER.projectSpace |
460 | 482 | parms.parent←config.CIDER.parent |
461 | 483 | parms.quietFlag←1 |
| 484 | + :AndIf {⍵:1 ⋄ 1 YesOrNo'Project successfully created; open as well?' ⋄ 1}quietFlag |
462 | 485 | :AndIf P.OpenProject parms |
463 | 486 | r←'Project created and opened' |
464 | 487 | :Else |
|
518 | 541 | :Else |
519 | 542 | name←Args._1 |
520 | 543 | :If ~(⊃Args._1)∊'#⎕' |
| 544 | + 'Not a valid APL name'Assert(⎕NS'').{0=⎕NC ⍵}name~'[]' |
521 | 545 | list←P.ListOpenProjects 0 |
522 | 546 | :If 0<≢list |
523 | 547 | :If 1=+/bool←name∘≡¨{⍵↓⍨⍵⍳'.'}¨list[;1] |
|
698 | 722 | :Until isOkay |
699 | 723 | ∇ |
700 | 724 |
|
701 | | - ∇ r←SelectFromAliases dummy;data;row |
| 725 | + ∇ r←{caption}SelectFromAliases data;row |
702 | 726 | r←⍬ |
703 | | - :If 0<≢data←P.GetAliasFileContent |
| 727 | + caption←{0<⎕NC ⍵:⍎⍵ ⋄ ''}'caption' |
| 728 | + :If 0=≢data |
| 729 | + data←P.GetAliasFileContent |
| 730 | + :EndIf |
| 731 | + :If 0<≢data |
704 | 732 | data[;1]←{'[',⍵,']'}¨data[;1] |
| 733 | + caption←'Select project to be opened',({0=≢⍵:⍵ ⋄ ' ',⍵,' '}caption),':' |
705 | 734 | :AndIf ⍬≢row←'Select project to be opened:'SelectOneItem↓⎕FMT data |
706 | 735 | r←row⊃data[;2] |
707 | 736 | :EndIf |
|
0 commit comments