diff --git a/Makefile b/Makefile index ec3c005..2abedb6 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ test-template: cleanup-test-dir --ProjectName my-go-project \ --IncludeReadme no \ --ProjectDescription "bla bla" \ - --ExampleType simple + --ProjectType simple cd $(TMP_DIR) &&\ make diff --git a/README.md b/README.md index 8776bbc..ea42148 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,8 @@ inputs: - id: IncludeReadme text: Would you like to include the readme file? type: yesno - - id: ExampleType - text: Select example type + - id: ProjectType + text: Select project type type: select options: - simple @@ -102,10 +102,10 @@ go-archetype transform --transformations=transformations.yml \ -- \ --ProjectName my-go-project \ --IncludeReadme yes \ - --ExampleType simple + --ProjectType simple ``` -In this example there are following inputs: `ProjectName`, `IncludeReadme` and `ExampleType`. +In this example there are following inputs: `ProjectName`, `IncludeReadme` and `ProjectType`. To seperate program args from user input we use `--`. After the `--` the list of user inputs is provided. @@ -377,18 +377,18 @@ Select allows to select one of the options and include section depends on select ```yml - name: simple type: include - region_marker: __SIMPLE__ - condition: "eq .ExampleType \"simple\"" + region_marker: __ProjectType_SIMPLE__ + condition: "eq .ProjectType \"simple\"" files: ["main.go"] - name: medium type: include - region_marker: __MEDIUM__ - condition: "eq .ExampleType \"medium\"" + region_marker: __ProjectType_MEDIUM__ + condition: "eq .ProjectType \"medium\"" files: ["main.go"] - name: advanced type: include - region_marker: __ADVANCED__ - condition: "eq .ExampleType \"advanced\"" + region_marker: __ProjectType_ADVANCED__ + condition: "eq .ProjectType \"advanced\"" files: ["main.go"] ``` diff --git a/inputs/cli_test.go b/inputs/cli_test.go index 6f1b87d..95b1537 100644 --- a/inputs/cli_test.go +++ b/inputs/cli_test.go @@ -66,9 +66,6 @@ func TestParseSelectCLIArgsInputs(t *testing.T) { require.NoError(t, err) assert.False(p.Answered) - err = ParseCLIArgsInputs(&mockInputsCollector{prompters: []Prompter{p}}, []string{"--s", "simple"}) - require.NoError(t, err) - err = ParseCLIArgsInputs(&mockInputsCollector{prompters: []Prompter{p}}, []string{"--s", "simple"}) require.NoError(t, err) assert.True(p.Answered) diff --git a/main.go b/main.go index f6d9bf4..cdab25b 100644 --- a/main.go +++ b/main.go @@ -8,17 +8,17 @@ import ( // See the README.md file for specification // END __INCLUDE_README__ -// BEGIN __SIMPLE__ +// BEGIN __ProjectType_SIMPLE__ // Simple section -// END __SIMPLE__ +// END __ProjectType_SIMPLE__ -// BEGIN __MEDIUM__ +// BEGIN __ProjectType_MEDIUM__ // Medium section -// END __MEDIUM__ +// END __ProjectType_MEDIUM__ -// BEGIN __ADVANCED__ +// BEGIN __ProjectType_ADVANCED__ // Advanced section -// END __ADVANCED__ +// END __ProjectType_ADVANCED__ func main() { cmd.Execute() diff --git a/transformations.yml b/transformations.yml index e85fb77..413fd86 100644 --- a/transformations.yml +++ b/transformations.yml @@ -9,8 +9,8 @@ inputs: - id: ProjectDescription text: Please provide a long project description type: text - - id: ExampleType - text: Select example type + - id: ProjectType + text: Select project type type: select options: [ "simple", "medium", "advanced" ] before: @@ -45,18 +45,18 @@ transformations: files: ["*.go", "**/*.go"] - name: simple type: include - region_marker: __SIMPLE__ - condition: eq .ExampleType "simple" + region_marker: __ProjectType_SIMPLE__ # Instantiates Simple project + condition: eq .ProjectType "simple" files: ["main.go"] - - name: simple + - name: medium type: include - region_marker: __MEDIUM__ - condition: eq .ExampleType "medium" + region_marker: __ProjectType_MEDIUM__ # Instantiates Medium project + condition: eq .ProjectType "medium" files: ["main.go"] - name: advanced type: include - region_marker: __ADVANCED__ - condition: eq .ExampleType "advanced" + region_marker: __ProjectType_ADVANCED__ # Instantiates Advanced project + condition: eq .ProjectType "advanced" files: ["main.go"] after: operations: