Skip to content

Commit

Permalink
chore: describe select option according to the repo style (#27)
Browse files Browse the repository at this point in the history
* Aligning with example theme.

(cherry picked from commit bd0c973)

* Aligning with the example theme.

(cherry picked from commit 885b440)

* Aligning with the example theme.

(cherry picked from commit 1ec5b5e)

---------

Co-authored-by: Viacheslav Isaev <[email protected]>
  • Loading branch information
titusjaka and Viacheslav Isaev authored Nov 10, 2023
1 parent 740405f commit 3be0b6b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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"]
```

Expand Down
3 changes: 0 additions & 3 deletions inputs/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 9 additions & 9 deletions transformations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3be0b6b

Please sign in to comment.