You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-27Lines changed: 33 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,29 +54,42 @@ Gherkin Utils is [available on Maven Central](https://central.sonatype.com/artif
54
54
55
55
## Command line
56
56
57
+
```bash
58
+
-> npx @cucumber/gherkin-utils format features
59
+
❌ 7 files failed to format
60
+
🥒 14 files left unchanged
61
+
🥒 25 files reformatted
62
+
```
63
+
57
64
To run Gherkin Utils as a formatter, try any of the following:
58
65
59
-
```console
66
+
```bash
60
67
# Format `file.feature`
61
68
npx @cucumber/gherkin-utils format features/file.feature
69
+
# Format `one.feature` and `two.feature`
70
+
npx @cucumber/gherkin-utils format features/one.feature features/two.feature
62
71
# Format all feature files in `features/` (and any subdirectories)
63
72
npx @cucumber/gherkin-utils format features/
73
+
# Format all feature files ending with `_test.feature` in `features`
74
+
npx @cucumber/gherkin-utils format features/**/*_test.feature
64
75
# Check files that would be reformatted in `features/`
65
76
npx @cucumber/gherkin-utils format --check features/
66
77
# Check files that would be reformatted in `features/` and output the diff
67
78
npx @cucumber/gherkin-utils format --diff features/
68
79
```
69
80
70
-
The following example translates all `.feature` files to `.feature.md` files and then deletes the `.feature` files (see [Markdown with Gherkin](https://github.com/cucumber/common/blob/main/gherkin/MARKDOWN_WITH_GHERKIN.md)).
71
-
**Note**: Globs must be quoted to prevent the shell from expanding the globs.
81
+
To convert to [Markdown with Gherkin](https://github.com/cucumber/common/blob/main/gherkin/MARKDOWN_WITH_GHERKIN.md) or feature files while formatting, try the following:
72
82
73
-
```console
74
-
npx @cucumber/gherkin-utils format --move "features/**/*.feature" "features/**/*.feature.md"
83
+
```bash
84
+
# Format all feature files in `features/` (and any subdirectories) and convert to gherkin markdown
85
+
npx @cucumber/gherkin-utils format --to-syntax=markdown features/
86
+
# Format all feature files in `features/` (and any subdirectories) and convert to gherkin
87
+
npx @cucumber/gherkin-utils format --to-syntax=gherkin features/
75
88
```
76
89
77
90
For more details on usage, see the help menu.
78
91
79
-
```console
92
+
```bash
80
93
npx @cucumber/gherkin-utils --help
81
94
```
82
95
@@ -89,35 +102,31 @@ This module can also be used as a library. It provides two main utilities, `pret
89
102
This function takes a GherkinDocument as input and returns a pretty-printed representation in Gherkin or Markdown.
// TODO: Default to running against the `features` directory
9
+
constfileFormats=['gherkin','markdown']
10
+
11
+
// TODO: Default to running against the `features` directory?
10
12
program
11
13
.command('format')
12
-
.arguments('[paths...]')
14
+
.argument(
15
+
'[paths...]',
16
+
'One or more .feature or .feature.md files, or directories containing such files'
17
+
)
13
18
.option(
14
19
'--check',
15
20
'Avoid writing any formatted files back; instead, exit with a non-zero status code if any files would have been modified, and zero otherwise'
@@ -19,15 +24,11 @@ program
19
24
'Avoid writing any formatted files back; instead, output a diff of changes that would be made and exit with a non-zero status code if any files would have been modified, and zero otherwise'
20
25
)
21
26
.option('-l, --language <ISO 639-1>','specify the language (dialect) of the source')
0 commit comments