@@ -24,6 +24,15 @@ enum MicroTargetType: String {
2424 case demo = " Demo "
2525}
2626
27+ struct ModuleInfo {
28+ let moduleName : String
29+ let hasInterface : Bool
30+ let hasTesting : Bool
31+ let hasUnitTests : Bool
32+ let hasUITests : Bool
33+ let hasDemo : Bool
34+ }
35+
2736let fileManager = FileManager . default
2837let currentPath = " ./ "
2938let bash = Bash ( )
@@ -175,6 +184,62 @@ func updateFileContent(
175184 try ? writeHandle. close ( )
176185}
177186
187+ func makeModuleInfo( ) -> ModuleInfo {
188+ print ( " Enter module name " , terminator: " : " )
189+ let moduleInput = readLine ( )
190+ guard let moduleNameUnwrapping = moduleInput, !moduleNameUnwrapping. isEmpty else {
191+ print ( " Module name is empty " )
192+ exit ( 1 )
193+ }
194+ let moduleName = moduleNameUnwrapping
195+ print ( " Module name: \( moduleName) \n " )
196+
197+ print ( " This module has a 'Interface' Target? (y \\ n, default = n) " , terminator: " : " )
198+ let hasInterface = readLine ( ) ? . lowercased ( ) == " y "
199+
200+ print ( " This module has a 'Testing' Target? (y \\ n, default = n) " , terminator: " : " )
201+ let hasTesting = readLine ( ) ? . lowercased ( ) == " y "
202+
203+ print ( " This module has a 'UnitTests' Target? (y \\ n, default = n) " , terminator: " : " )
204+ let hasUnitTests = readLine ( ) ? . lowercased ( ) == " y "
205+
206+ print ( " This module has a 'UITests' Target? (y \\ n, default = n) " , terminator: " : " )
207+ let hasUITests = readLine ( ) ? . lowercased ( ) == " y "
208+
209+ print ( " This module has a 'Demo' Target? (y \\ n, default = n) " , terminator: " : " )
210+ let hasDemo = readLine ( ) ? . lowercased ( ) == " y "
211+
212+ return ModuleInfo (
213+ moduleName: moduleName,
214+ hasInterface: hasInterface,
215+ hasTesting: hasTesting,
216+ hasUnitTests: hasUnitTests,
217+ hasUITests: hasUITests,
218+ hasDemo: hasDemo
219+ )
220+ }
221+
222+ func checkModuleInfo( ) -> Bool {
223+ print ( " " )
224+ print ( " ------------------------------------------------------------------------------------------------------------------------ " )
225+ print ( " Is this the correct module information you are generating? (y \\ n, default = y) " )
226+ print ( " Layer: \( layer. rawValue) " )
227+ print ( " Module name: \( moduleName) " )
228+ print ( " interface: \( hasInterface) , testing: \( hasTesting) , unitTests: \( hasUnitTests) , uiTests: \( hasUITests) , demo: \( hasDemo) " )
229+ print ( " ------------------------------------------------------------------------------------------------------------------------ " )
230+
231+ guard var checkInput = readLine ( ) else {
232+ exit ( 1 )
233+ }
234+
235+ if checkInput. isEmpty {
236+ checkInput = " y "
237+ }
238+
239+ let isCorrect = checkInput. lowercased ( ) == " y "
240+ return !isCorrect
241+ }
242+
178243// MARK: - Starting point
179244
180245print ( " Enter layer name \n (Feature | Domain | Core | Shared | UserInterface) " , terminator: " : " )
@@ -190,40 +255,26 @@ else {
190255let layer = layerUnwrapping
191256print ( " Layer: \( layer. rawValue) \n " )
192257
193- print ( " Enter module name " , terminator: " : " )
194- let moduleInput = readLine ( )
195- guard let moduleNameUnwrapping = moduleInput, !moduleNameUnwrapping. isEmpty else {
196- print ( " Module name is empty " )
197- exit ( 1 )
258+ var moduleName : String = " "
259+ var hasInterface : Bool = false
260+ var hasTesting : Bool = false
261+ var hasUnitTests : Bool = false
262+ var hasUITests : Bool = false
263+ var hasDemo : Bool = false
264+
265+ repeat {
266+ let moduleInfo = makeModuleInfo ( )
267+ moduleName = moduleInfo. moduleName
268+ hasInterface = moduleInfo. hasInterface
269+ hasTesting = moduleInfo. hasTesting
270+ hasUnitTests = moduleInfo. hasUnitTests
271+ hasUITests = moduleInfo. hasUITests
272+ hasDemo = moduleInfo. hasDemo
198273}
199- var moduleName = moduleNameUnwrapping
200- print ( " Module name: \( moduleName) \n " )
201-
202- print ( " This module has a 'Interface' Target? (y \\ n, default = n) " , terminator: " : " )
203- let hasInterface = readLine ( ) ? . lowercased ( ) == " y "
204-
205- print ( " This module has a 'Testing' Target? (y \\ n, default = n) " , terminator: " : " )
206- let hasTesting = readLine ( ) ? . lowercased ( ) == " y "
207-
208- print ( " This module has a 'UnitTests' Target? (y \\ n, default = n) " , terminator: " : " )
209- let hasUnitTests = readLine ( ) ? . lowercased ( ) == " y "
210-
211- print ( " This module has a 'UITests' Target? (y \\ n, default = n) " , terminator: " : " )
212- let hasUITests = readLine ( ) ? . lowercased ( ) == " y "
213-
214- print ( " This module has a 'Demo' Target? (y \\ n, default = n) " , terminator: " : " )
215- let hasDemo = readLine ( ) ? . lowercased ( ) == " y "
216-
217- print ( " " )
218-
274+ while checkModuleInfo ( )
275+
219276registerModuleDependency ( )
220277
221- print ( " " )
222- print ( " ------------------------------------------------------------------------------------------------------------------------ " )
223- print ( " Layer: \( layer. rawValue) " )
224- print ( " Module name: \( moduleName) " )
225- print ( " interface: \( hasInterface) , testing: \( hasTesting) , unitTests: \( hasUnitTests) , uiTests: \( hasUITests) , demo: \( hasDemo) " )
226- print ( " ------------------------------------------------------------------------------------------------------------------------ " )
227278print ( " ✅ Module is created successfully! " )
228279
229280// MARK: - Bash
0 commit comments