Skip to content

Commit f43fcd5

Browse files
authored
Merge pull request #1 from DannyBen/refactor/argfile
Refactor as a single command and add `.shellkin` argfile support
2 parents e51188e + 0ea135d commit f43fcd5

55 files changed

Lines changed: 1003 additions & 986 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Run Bats tests
1818
run: bats --recursive --print-output-on-failure test
1919
- name: Run Shellkin tests
20-
run: ./shellkin test
20+
run: ./shellkin
2121

2222
ubuntu_setup:
2323
name: Setup on Ubuntu

AGENTS.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@ Shellkin is a Bashly-based Gherkin-style test framework for shell scripts.
44

55
## Orientation
66

7-
- The project is organized by concern, not by command:
8-
- `src/lib/syntax` parses and validates the language
9-
- `src/lib/file` reads project files and orchestrates them
10-
- `src/lib/runtime` contains framework execution internals
7+
- The project is organized by concept, not by command:
8+
- `src/lib/feature` contains feature parsing and execution
9+
- `src/lib/stepdef` contains step definition parsing and file loading
10+
- `src/lib/step` contains step matching and execution
11+
- `src/lib/support` contains support file loading
1112
- `src/lib/user_helpers` contains step-author-facing helpers
1213
- `src/lib/output` contains user-visible screen output
1314
- `src/lib/core` contains small shared primitives
14-
- Bashly command behavior lives in `src/commands`.
15+
- Bashly command behavior lives in `src/root_command.sh`.
1516
- Repo-level `features/` are used both for dogfooding and as examples.
1617

1718
## Conventions
1819

1920
- Prefer small, focused functions.
2021
- Do not use nested function definitions; private helpers should still live at file scope.
22+
- Name private helpers with a `__` suffix on the namespace, such as `feature__helper`.
23+
- Place private helpers after the public functions in each file.
2124
- Use uppercase names for shared/framework state and lowercase for local variables.
25+
- Do not access CLI input such as `args[...]` anywhere under `src/lib`; normalize CLI input in the command layer and pass explicit parameters into lib functions.
2226
- Keep user-facing helper functions separate from framework internals.
2327
- Keep output logic isolated from parsing and runtime logic.
2428
- Prefer established Gherkin conventions and syntax over custom forms when practical.
@@ -27,6 +31,7 @@ Shellkin is a Bashly-based Gherkin-style test framework for shell scripts.
2731

2832
- Prefer readable Bats tests over clever ones.
2933
- Use focused test files per function or per small public API surface.
34+
- Do not test private `__` helpers directly.
3035
- When file content is the subject of the test, prefer inline heredoc fixtures.
3136
- `write_file` in tests writes under `TEST_ROOT`.
3237

README.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Feature: --help
1414
1515
Scenario: Run --help
1616
When I run 'shellkin --help'
17-
Then the output should include 'shellkin COMMAND'
17+
Then the output should include 'shellkin [TARGET] [OPTIONS]'
1818
```
1919

2020
and back them with shell step definitions:
@@ -36,8 +36,8 @@ Indenting the step body is recommended for readability, but optional.
3636
This setup script will download the latest shellkin release executable as well
3737
as the man pages.
3838

39-
```shell
40-
$ curl -Ls get.dannyb.co/shellkin/setup | bash
39+
```bash
40+
curl -Ls get.dannyb.co/shellkin/setup | bash
4141
```
4242

4343
Feel free to inspect the [setup script](setup) before running.
@@ -63,7 +63,7 @@ through the repository `features/` directory.
6363
Implemented pieces include:
6464

6565
- feature discovery from a directory or a single `.feature` file
66-
- optional support script loading from `support.sh`
66+
- optional support script loading with `--load`
6767
- step definition loading from `step_definitions/*.sh` and `*.bash`
6868
- step matching with `{token}` placeholders
6969
- `Background`, `Scenario`, `Given` / `When` / `Then`, `And` / `But`, and `*`
@@ -93,27 +93,50 @@ Implemented pieces include:
9393

9494
```bash
9595
# Run all repo features:
96-
shellkin test
96+
shellkin
9797

9898
# Validate feature and step definition files without executing steps:
99-
shellkin validate
99+
shellkin --validate
100100

101101
# Stop after the first failing scenario:
102-
shellkin test --fail-fast
102+
shellkin --fail-fast
103103

104104
# Run a specific directory:
105-
shellkin test path/to/features
105+
shellkin path/to/features
106106

107107
# Run a single feature file:
108-
shellkin test path/to/features/example.feature
108+
shellkin path/to/features/example.feature
109109
```
110110

111111
When a step fails, the remaining steps in that scenario are marked as skipped
112112
and are not executed.
113113

114-
Use `shellkin validate` to check feature structure and step-definition matching
114+
Use `shellkin --validate` to check feature structure and step-definition matching
115115
without running any step bodies.
116116

117+
## Configuration with `.shellkin`
118+
119+
Shellkin supports configuration from a `.shellkin` argfile in the current
120+
working directory.
121+
122+
This is useful for project-level defaults such as the default target,
123+
step-definitions directory, and support files:
124+
125+
```text
126+
--default-target tests
127+
--stepdefs steps
128+
--load first_support.sh
129+
--load second_support.sh
130+
```
131+
132+
The argfile format is intentionally simple:
133+
134+
- Empty lines are ignored
135+
- Lines starting with `#` are ignored
136+
- Each other line becomes one argument
137+
- A flag and value can be written on one line or on two lines
138+
- Matching outer quotes are stripped
139+
117140
## AI Agent Skill
118141

119142
This repository also provides a Codex skill for AI agents that need to write
@@ -145,26 +168,24 @@ Shellkin expects this structure:
145168

146169
```text
147170
features/
148-
├── support.sh
149171
├── step_definitions/
150172
│ └── core.sh
151173
└── example.feature
152174
```
153175

154176
- Feature files live in the target directory.
155-
- If present, `support.sh` is sourced before step definitions are loaded.
156177
- Step definitions live in `step_definitions/` under that same directory.
157-
- Set `SHELLKIN_SUPPORT_FILE` to change the support script name relative to the
158-
features directory.
178+
- Support files are loaded only when passed with `--load`.
179+
- `--stepdefs` and `--load` paths are relative to the features directory.
159180

160181
## Step Definitions
161182

162183
Step definitions are shell snippets declared in files under
163184
`step_definitions/`.
164185

165-
To share helper functions across step definition files, place them in
166-
`support.sh` in the features directory. Shellkin sources this file before it
167-
loads step definitions. You can rename it with `SHELLKIN_SUPPORT_FILE`.
186+
To share helper functions across step definition files, place them in a support
187+
script under the features directory and load it with `--load` or through
188+
`.shellkin`.
168189

169190
```bash
170191
@When I run '{command}'
@@ -270,7 +291,7 @@ and the [rush features](https://github.com/DannyBen/rush/tree/master/features).
270291
If you used the setup script, you can run this uninstall script:
271292

272293
```shell
273-
$ curl -Ls get.dannyb.co/shellkin/uninstall | bash
294+
curl -Ls get.dannyb.co/shellkin/uninstall | bash
274295
```
275296

276297
## Contributing / Support

doc/shellkin-feature.5

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ Scenario: Create a file
133133
Then the file \(aqsomefile\(aq should exist
134134
.EE
135135
.SH SEE ALSO
136-
\f[B]shellkin\f[R](1), \f[B]shellkin\-test\f[R](1),
137-
\f[B]shellkin\-stepdefs\f[R](5)
136+
\f[B]shellkin\f[R](1), \f[B]shellkin\-stepdefs\f[R](5)
138137
.SH SOURCE CODE
139138
https://github.com/dannyben/shellkin
140139
.SH ISSUE TRACKER

doc/shellkin-feature.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Scenario: Create a file
163163
SEE ALSO
164164
==================================================
165165

166-
**shellkin**(1), **shellkin-test**(1), **shellkin-stepdefs**(5)
166+
**shellkin**(1), **shellkin-stepdefs**(5)
167167

168168

169169
SOURCE CODE

doc/shellkin-stepdefs.5

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ temp_workspace() \f[B]{\f[R]
145145
\f[B][[\f[R] \-f \(dq$path\(dq \f[B]]]\f[R]
146146
.EE
147147
.SH SEE ALSO
148-
\f[B]shellkin\f[R](1), \f[B]shellkin\-test\f[R](1),
149-
\f[B]shellkin\-feature\f[R](5)
148+
\f[B]shellkin\f[R](1), \f[B]shellkin\-feature\f[R](5)
150149
.SH SOURCE CODE
151150
https://github.com/dannyben/shellkin
152151
.SH ISSUE TRACKER

doc/shellkin-stepdefs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ temp_workspace() {
170170
SEE ALSO
171171
==================================================
172172

173-
**shellkin**(1), **shellkin-test**(1), **shellkin-feature**(5)
173+
**shellkin**(1), **shellkin-feature**(5)
174174

175175

176176
SOURCE CODE

doc/shellkin-test.1

Lines changed: 0 additions & 23 deletions
This file was deleted.

doc/shellkin-test.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

doc/shellkin-validate.1

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)