|
1 | | - r←Run(path_ recursive stats all noOf);acreFlag;F;A;bool;projects;buff;pathFlag;path;projects1;promaFlag;projects2;ind;ref |
| 1 | + r←Run(path_ recursive stats all noOf);hasOpenAcreProjects;F;A;bool;projects;buff;pathFlag;path;projects1;hasOpenCiderProjects;projects2;ind;ref;name;isAcreProject;isCiderProject |
2 | 2 | ⍝ Handles the following cases: |
3 | 3 | ⍝ * Investigate the workspace (simple namespace or #) |
4 | 4 | ⍝ * Investigate (currently tracked/opened) acre projects |
5 | | -⍝ * Investigate (currently tracked/opened) ProMa projects |
6 | | -⍝ * Investigate an acre project that is not currently tracked (not open) |
7 | | - A←APLTreeUtils2 ⋄ F←FilesAndDirs |
| 5 | +⍝ * Investigate (currently tracked/opened) Cider projects |
| 6 | +⍝ * Investigate a folder |
| 7 | + A←##.APLTreeUtils2 ⋄ F←##.FilesAndDirs |
8 | 8 | r←'' |
9 | | - pathFlag←acreFlag←0 |
| 9 | + pathFlag←hasOpenAcreProjects←hasOpenCiderProjects←0 |
10 | 10 | path←path_ |
| 11 | + isAcreProject←isCiderProject←0 |
11 | 12 | :If 0=≢path ⍝ Only true if we deal with a project |
| 13 | + projects1←projects2←0 2⍴'' |
12 | 14 | :If 9=⎕SE.⎕NC'acre' |
13 | 15 | projects1←⎕SE.acre.Projects ⍬ |
14 | | - acreFlag←0<≢projects1 |
| 16 | + hasOpenAcreProjects←0<≢projects1 |
15 | 17 | :EndIf |
16 | | - :If 0=⎕SE.⎕NC'ProMa' |
17 | | - {}⎕SE.UCMD'ProMa.Version' |
| 18 | + :If 9=⎕SE.⎕NC'Cider' |
| 19 | + {}⎕SE.UCMD'Cider.Version' |
| 20 | + hasOpenCiderProjects←0<≢projects2←⎕SE.Cider.ListOpenProjects 0 |
18 | 21 | :EndIf |
19 | | - projects2←⎕SE.ProMa.ListProjects 0 |
20 | | - :If promaFlag←0<≢projects2 |
21 | | - projects2←(⍪projects2),{⍵.PromaConfig.HOME}∘⍎¨projects2 |
22 | | - :Else |
23 | | - projects2←0 2⍴⍬ |
24 | | - :EndIf |
25 | | - :If 0<+/≢¨projects1,projects2 |
26 | | - projects←(projects1,1)⍪(projects2,2) |
27 | | - :Else |
| 22 | + projects←(projects1,1)⍪(projects2,2) |
| 23 | + :If 0=≢projects |
28 | 24 | path←'expand'F.NormalizePath F.PWD,F.CurrentSep ⍝ Current dir is the best we can do here |
29 | 25 | pathFlag←1 |
30 | 26 | :EndIf |
31 | 27 | :ElseIf ~(1⍴path)∊'#⎕' ⍝ True if it's a folder path |
32 | 28 | path←('expand'F.NormalizePath path),F.CurrentSep |
| 29 | + ('Is not a folder: ',path)⎕SIGNAL 6/⍨~F.IsDir path |
33 | 30 | pathFlag←1 |
34 | 31 | :EndIf |
35 | 32 | :If 0=≢path |
36 | | - :AndIf 0=acreFlag |
37 | | - path←F.PWD,F.CurrentSep |
38 | | - pathFlag←F.IsDir path,'APLSource' |
| 33 | + :AndIf 0=hasOpenAcreProjects+hasOpenCiderProjects |
| 34 | + path←F.PWD,F.CurrentSep,'APLSource' |
| 35 | + pathFlag←F.IsDir path |
39 | 36 | :EndIf |
40 | | - :If acreFlag∨promaFlag |
41 | | - ind←SelectProject{⍵[;0 1],('acre project' 'ProMa project')[⍵[;2]-1]}projects |
42 | | - →(¯1=ind)/0 |
43 | | - path←1⊃projects[ind;] |
44 | | - projects1[;1]←{'/'@(⍸'\'=⍵)⊣⍵}¨projects1[;1] |
45 | | - projects2[;1]←{'/'@(⍸'\'=⍵)⊣⍵}¨projects2[;1] |
| 37 | + :If hasOpenAcreProjects∨hasOpenCiderProjects |
| 38 | + :If 1=≢projects |
| 39 | + name←↑projects |
| 40 | + :If 1=≢projects1 |
| 41 | + path←↑projects1[;1] |
| 42 | + path←(~all){⍵.AcreConfig.ProjectFolder,⍺/'APLSource/'}⍎name ⍝ Fixed in acre |
| 43 | + isAcreProject←1 |
| 44 | + :Else |
| 45 | + path←(~all){⍵.HOME,'/',⍺/⍵.CIDER.source}⍎(↑projects2),'.CiderConfig' |
| 46 | + isCiderProject←1 |
| 47 | + :EndIf |
| 48 | + :Else |
| 49 | + ind←SelectProject{⍵[;0 1],('acre project' 'Cider project')[⍵[;2]-1]}projects |
| 50 | + →(¯1=ind)/0 |
| 51 | + name←↑projects[ind;] |
| 52 | + isAcreProject←∨/name∘≡¨projects1[;0] |
| 53 | + isCiderProject←∨/name∘≡¨projects2[;0] |
| 54 | + :If isCiderProject |
| 55 | + path←(~all){⍵.HOME,'/',⍺/⍵.CIDER.source}⍎name,'.CiderConfig' |
| 56 | + :ElseIf isAcreProject |
| 57 | + path←(~all){⍵.AcreConfig.ProjectFolder,⍺/'APLSource/'}⍎name ⍝ Fixed in acre |
| 58 | + :EndIf |
| 59 | + :EndIf |
| 60 | + projects1[;1]←F.NormalizePath projects1[;1] |
| 61 | + projects2[;1]←F.NormalizePath projects2[;1] |
46 | 62 | :EndIf |
47 | | - :If acreFlag∨promaFlag∨pathFlag |
| 63 | + :If isAcreProject∨isCiderProject∨pathFlag |
48 | 64 | path←'expand'F.NormalizePath path,F.CurrentSep |
49 | | - :If F.IsDir path |
| 65 | + :If 0<≢#.⎕NL⍳16 |
| 66 | + :AndIf F.IsDir path |
50 | 67 | r←⍉⊃('recursive'recursive)('type'(0 1 3))F.Dir path |
51 | 68 | r←(r[;1]=2)⌿r ⍝ Only regular files |
52 | | - :If 0=all |
| 69 | + :If all |
| 70 | + r←(~{≢'[/\\]\.git[/\\]'⎕S 0⊣⍵}¨r[;0])⌿r |
| 71 | + :Else |
53 | 72 | r←(({2⊃⎕NPARTS ⍵}¨r[;0])∊GetExtensions)⌿r |
54 | 73 | :EndIf |
55 | 74 | r[;2]←↓A.FormatDateTime⊃r[;2] |
|
62 | 81 | ⍝ 0 in case text was provided as argument |
63 | 82 | ⍝ An integer otherwise. |
64 | 83 | :If ⍬≡noOf |
65 | | - r←((10↑¨r[;1])≡¨⊂10↑1⊃r[¯1+≢r;])⌿r |
| 84 | + r←((10↑¨r[;1])≡¨⊂10↑1⊃r[¯1+≢r;])⌿r ⍝ All from the day with the latest change |
66 | 85 | :ElseIf 0≢noOf |
67 | 86 | :If ¯1=×noOf |
68 | 87 | buff←10↑¨r[;1] ⍝ YYYY-MM-DD |
|
83 | 102 | :Else |
84 | 103 | r[;0]←(≢path)↓¨r[;0] |
85 | 104 | :EndIf |
| 105 | + :ElseIf all |
| 106 | + r[;0]←(≢path){∧/~'/\'∊⍵:⍵ ⋄ ⍺↓⍵}¨r[;0] |
86 | 107 | :Else |
87 | | - :If (⊂{'/'@(⍸'\'=⍵)⊣⍵}path)∊AddSlash projects1[;1] |
| 108 | + :If ∨/name∘≡¨projects1[;0] |
88 | 109 | r[;0]←⎕SE.acre.Itemname r[;0] |
89 | | - :ElseIf (⊂{'/'@(⍸'\'=⍵)⊣⍵}path)∊AddSlash projects2[;1] |
90 | | - r[;0]←⎕SE.Link.GetItemName{'/'@(⍸'\'=⍵)⊣⍵}¨r[;0] |
| 110 | + :ElseIf ∨/name∘≡¨projects2[;0] |
| 111 | + r[;0]←⎕SE.Link.GetItemName¨F.EnforceSlash¨r[;0] |
91 | 112 | :EndIf |
| 113 | + r←(0<≢¨r[;0])⌿r |
92 | 114 | :EndIf |
93 | 115 | :EndIf |
94 | 116 | :EndIf |
|
0 commit comments