|
1 | 1 | package agrupamento_de_dados |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + // "go/format" removed as it does not contain MenuOptions |
| 5 | + |
| 6 | + base "github.com/fabianoflorentino/aprendago/pkg/base_content" |
4 | 7 | "github.com/fabianoflorentino/aprendago/pkg/format" |
5 | | - "github.com/fabianoflorentino/aprendago/pkg/logger" |
6 | | - "github.com/fabianoflorentino/aprendago/pkg/section" |
7 | 8 | ) |
8 | 9 |
|
9 | | -// menu generates a list of menu options based on the provided menu slice and root directory. |
10 | | -// It initializes a section using the given root directory and returns a slice of MenuOptions, |
11 | | -// each containing an option string and an associated execution function. |
12 | | -// |
13 | | -// Parameters: |
14 | | -// - menu: A slice of strings representing the menu options. |
15 | | -// - rootDir: A string representing the root directory for initializing the section. |
16 | | -// |
17 | | -// Returns: |
18 | | -// - A slice of format.MenuOptions, where each option has an associated execution function. |
19 | | -// If an error occurs during section initialization, it logs the error and returns nil. |
20 | 10 | func Menu(menu []string) []format.MenuOptions { |
21 | | - section, err := section.New(rootDir) |
22 | | - if err != nil { |
23 | | - logger.New("Error creating section: ", err.Error()).Register() |
| 11 | + m := base.New() |
| 12 | + |
| 13 | + newFlag := []string{ |
| 14 | + flagArray, |
| 15 | + flagSliceLiteralComposta, |
| 16 | + flagSliceForRange, |
| 17 | + flagSliceFatiandoOuDeletando, |
| 18 | + flagSliceAnexando, |
| 19 | + flagSliceMake, |
| 20 | + flagSliceMultiDimensional, |
| 21 | + flagSliceSurpresaArraySubjacente, |
| 22 | + flagMapsIntroducao, |
| 23 | + flagMapsRangeEDeletando, |
24 | 24 | } |
25 | 25 |
|
26 | | - return []format.MenuOptions{ |
27 | | - {Options: flagArray, ExecFunc: func() { sectionsAgrupamentoDeDados(array, section) }}, |
28 | | - {Options: flagSliceLiteralComposta, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceLiteralComposta, section) }}, |
29 | | - {Options: flagSliceForRange, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceForRange, section) }}, |
30 | | - {Options: flagSliceFatiandoOuDeletando, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceFatiandoOuDeletando, section) }}, |
31 | | - {Options: flagSliceAnexando, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceAnexando, section) }}, |
32 | | - {Options: flagSliceMake, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceMake, section) }}, |
33 | | - {Options: flagSliceMultiDimensional, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceMultiDimensional, section) }}, |
34 | | - {Options: flagSliceSurpresaArraySubjacente, ExecFunc: func() { sectionsAgrupamentoDeDados(sliceSurpresaArraySubjacente, section) }}, |
35 | | - {Options: flagMapsIntroducao, ExecFunc: func() { sectionsAgrupamentoDeDados(mapsIntroducao, section) }}, |
36 | | - {Options: flagMapsRangeEDeletando, ExecFunc: func() { sectionsAgrupamentoDeDados(mapsRangeEDeletando, section) }}, |
| 26 | + newExecFunc := []func(){ |
| 27 | + func() { m.SectionFormat(array, m.SectionFactory(rootDir)) }, |
| 28 | + func() { m.SectionFormat(sliceLiteralComposta, m.SectionFactory(rootDir)) }, |
| 29 | + func() { m.SectionFormat(sliceForRange, m.SectionFactory(rootDir)) }, |
| 30 | + func() { m.SectionFormat(sliceFatiandoOuDeletando, m.SectionFactory(rootDir)) }, |
| 31 | + func() { m.SectionFormat(sliceAnexando, m.SectionFactory(rootDir)) }, |
| 32 | + func() { m.SectionFormat(sliceMake, m.SectionFactory(rootDir)) }, |
| 33 | + func() { m.SectionFormat(sliceMultiDimensional, m.SectionFactory(rootDir)) }, |
| 34 | + func() { m.SectionFormat(sliceSurpresaArraySubjacente, m.SectionFactory(rootDir)) }, |
| 35 | + func() { m.SectionFormat(mapsIntroducao, m.SectionFactory(rootDir)) }, |
| 36 | + func() { m.SectionFormat(mapsRangeEDeletando, m.SectionFactory(rootDir)) }, |
37 | 37 | } |
38 | | -} |
39 | 38 |
|
40 | | -// sectionsAgrupamentoDeDados formats and processes sections of data under a given title. |
41 | | -// It utilizes the SectionProvider interface to handle the formatting logic. |
42 | | -// |
43 | | -// Parameters: |
44 | | -// - title: A string representing the title for the sections. |
45 | | -// - sections: An implementation of the section.SectionProvider interface |
46 | | -// that provides the functionality to format the sections. |
47 | | -func sectionsAgrupamentoDeDados(title string, sections section.SectionProvider) { |
48 | | - sections.Format(title) |
| 39 | + return m.Menu(newFlag, newExecFunc) |
49 | 40 | } |
0 commit comments